Hi,
No problem.
Try:
data.frame(col1=data,col2=as.character(factor(gsub("\\d+","",data),labels=c("positive","negative"))),stringsAsFactors=FALSE)
A.K.
Hello Arun,
Thank you so much, ?it works great.
But I some sets, the data contains some additional characters
also, like a1, a2, a3....b1,b2 and so on. in this case how to tag
positive and negative values?
initial data:
data<- c("a1",
"b1","b","b2","a2","a3","b","a","b3")
output expected:
col1 ?col2
a1 ? ? positive
b1 ? ? negative
b ? ? negative
b2 ? ? negative
a2 ? ? positive
a ? ? positive
b ? ? negative
a ? ? positive
b3 ? ? negative
How to use grep and tag the annotations..
Thanks
karthick
On Saturday, October 26, 2013 3:10 PM, arun <smartpink111 at yahoo.com>
wrote:
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
______________________________________________
R-help at 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.