Re: [R] help_if command_new column

2009-05-04 Thread David Winsemius
You should be looking at the ifelse function. Ihe if and else constructs are not appropriate for recoding because they do not return vectors. Much easier than all that folderol would be: df$Aggregation <- ifelse( df$Number>1, "School", "Solitary") On May 4, 2009, at 12:31 PM, barbara horta

[R] help_if command_new column

2009-05-04 Thread barbara horta e costa
Hi everyone, Do you know how to apply a If command to a vector in a data.frame, creating a new column? Example: If one species has "1" value in the Abundance column then it is "Solitary". If the abundance is higher than 1, is "School". I did: aggregationFunction <-function(x){ (if (x>1