mercredi 4 mars 2015

Make a vector from a function with elseif

I want to use a vector (Temp<-(-6:20)) as an input and in return get a vector (y). It does not work, I just get the Warning message:



"In if (Temp <= -5) { :
the condition has length > 1 and only the first element will be used"


The function:



my_funct<-function(Temp){ if(Temp<= -5){y<- 100}else if(Temp<=5){y<-Temp^2}else{y<-Temp}y}


Note: the function is simplified from my original one


Aucun commentaire:

Enregistrer un commentaire