Hello!
I am trying to get a logic estatement in R using the if function, but it is all 
the time comming and error, I have tryied different methods but nothing is 
working
the sentence is the following:

dispersal[1] <-  if (any (relativenes[1] < cost)) ((relativenes[1]- 
cost)/(relativenes[1]- cost*cost)) else 0
            for (i in 2: time){
            dispersal[i] <-  if (any (relativenes[i] < cost)) ((relativenes[i]- 
cost)/(relativenes[i]- cost*cost)) else 0   }


 dispersal[1] <-  if (relativenes[1] < cost) dispersal[1] <- ((relativenes[1]- 
cost)/(relativenes[1]- cost*cost)) else dispersal[1]<- 0
            for (i in 2: time){
            dispersal[i] <-  if  (relativenes[i] < cost)) dispersal[i] 
<-((relativenes[i]- cost)/(relativenes[i]- cost*cost)) else dispersal[i] <- 0   
}

dispersal[1] <-  if (relativenes[1] < cost)  {dispersal[1] <- ((relativenes[1]- 
cost)/(relativenes[1]- cost*cost))} else {dispersal[1]<- 0}
            for (i in 2: time){
            dispersal[i] <- if (relativenes[i] < cost) {dispersal[i] 
<-((relativenes[i]- cost)/(relativenes[i]- cost*cost))} else {dispersal[i] <- 
0}}
           
 Thanks Charo
                     
            

                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to