In the following data frame:
x <-c(rep (c ("s1", "s2", "s3"),each=5 ))
y <- c(rep(c("a", "b", "c", "d", "e"), 3) )
z<-c(1:15)
x_name <- "dimensions"
y_name <- "aspects"
z_name<-"value"
df <- data.frame(x,y,z)
names(df) <- c(x_name,y_name, z_name)
I would like to remove factor levels 'a' and 'b' from 'aspects'. When I try
df1<-subset(df, aspects !="a")
it works ok. However,
df1<-subset(df, aspects != c("a", "b"))
removes not all but just some of 'a' and 'b' and gives a warning :
longer object length is not a multiple of shorter object length.
Can you help me figure out what is wrong? Is there a way to use subset
to remove 'a' and 'b' in one go?