> Subsetting from a dataframe with only one variable > returns a vector, not a dataframe. > This seems somewhat inconsistent. > Wouldn't it be better if subsetting would respect > the structure completely? > > > v1<-1:4 > v2<-4:1 > df1<-data.frame(v1) > df2<-data.frame(v1,v2) > sel1<-c(TRUE,TRUE,TRUE,TRUE) > > > df1[sel1,]
df1[[sel1, , drop=FALSE] Should do what you want. Best, Matthias > [1] 1 2 3 4 > > df2[sel1,] > v1 v2 > 1 1 4 > 2 2 3 > 3 3 2 > 4 4 1 > > -- > Erich Neuwirth > Institute for Scientific Computing and > Didactic Center for Computer Science > University of Vienna > phone: +43-1-4277-39464 fax: +43-1-4277-39459 > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read > the posting guide! http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
