[R] Getting rid of rows matching a certain condition
arun
smartpink111 at yahoo.com
Thu Jun 13 19:03:40 CEST 2013
HI,
Please check this link (http://r.789695.n4.nabble.com/Remove-levels-td4669441.html). It was posted today.
df1<-subset(df, Trt!="blank")
df2<- df1
df1$Trt<- factor(df1$Trt)
levels(df1$Trt)
#[1] "Trt1" "Trt2"
#or
df2$Trt<-droplevels(df2$Trt)
levels(df2$Trt)
#[1] "Trt1" "Trt2"
A.K.
Hey guys
I am new and a beginner. So far I searched the forum for an answer. Did not found anything.
Here is the Problem.
I have a data.frame
Time <- c(1,2,1,1,2,2,3,3)
Trt <- factor(c("blank", "blank", "Trt1", "Trt1", "Trt1", "Trt2", "Trt2", "Trt2"))
OD600 <- c(0.1,0.2,0.18,0.3,0.16,0.21,0.25,0.16)
df <- data.frame(Time,Trt,OD600)
No I apply:
df<-subset(df, Trt!="blank")
So the data.frame has no rows matching Trt=blank" anymore (looking at the data set). So far so good.
However if I type in:
levels(df$Trt)
I get the result: [1] "blank" "Trt1" "Trt2"
Somehow it is still somwhere. How can I remove the blank from the data.frame definitely?
Thanks for the help.
More information about the R-help
mailing list