[R] dataframes with only one variable

From: Erich Neuwirth <erich.neuwirth_at_univie.ac.at>
Date: Thu 12 Jan 2006 - 02:02:10 EST


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,]

[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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jan 12 19:31:54 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:03 EST