在以下数据框中:
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)
我想删除因素级别&#39; a&#39;和&#39; b&#39;来自&#39;方面&#39;。当我尝试
df1<-subset(df, aspects !="a")
它运作正常。 但是,
df1<-subset(df, aspects != c("a", "b"))
除去了一些&#39; a&#39;和&#39; b&#39;并发出警告:
longer object length is not a multiple of shorter object length.
你可以帮我弄清楚出了什么问题吗?有没有办法使用subset
删除&#39; a&#39;和&#39; b&#39;一气呵成?