[R] dataframes with only one variable
Erich Neuwirth
erich.neuwirth at univie.ac.at
Wed Jan 11 16:02:10 CET 2006
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
More information about the R-help
mailing list