[R] find and add text

arun smartpink111 at yahoo.com
Sat Oct 26 21:05:20 CEST 2013


Hi,
You may try:
dat2 <- data.frame(col1=data,col2=as.character(factor(data,labels=c("positive","negative"))),stringsAsFactors=FALSE)


A.K.


Hello all, 

I have a data something like this; 

data<- c("a", "b","b","b","a","a","b","a","b") 

and I need to represent all "a"'s as "positive"  and "b"'s "negative" in data.frame something like this; 

data.frame output= 
col1  col2 
a     positive 
b     negative 
b     negative 
b     negative 
a     positive 
a     positive 
b     negative 
a     positive 
b     negative 

Thanks in advance for your solutions 

Thanks 
karthick



More information about the R-help mailing list