Skip to content
Prev 306304 / 398506 Next

create new column in a DF according to values from another column

On 26-09-2012, at 12:49, jeff6868 <geoffrey_klein at etu.u-bourgogne.fr> wrote:

            
DF[DF$number %in% c(1,7,11,16),"Station"] <- "V1"
DF[DF$number %in% c(4,14,20),"Station"] <- "V2"
DF[DF$number %in% c(3,17,19),"Station"] <- "V3"
DF

The Station column is of type character.
To make FINALDF identical you should add stringsAsFactors=FALSE to the arguments of data.frame.

Berend