Re: [R] Extracting some rows from a data frame - lapses into a vector

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Tue 16 Aug 2005 - 16:26:51 EST

Ajay Narottam Shah <ajayshah <at> mayin.org> writes:

>
> I have a data frame with one column "x":
>
> > str(data)
> `data.frame': 20 obs. of 1 variable:
> $ x: num 0.0495 0.0986 0.9662 0.7501 0.8621 ...
....
> Here, it looks like the operation
> data[1:10,]
> has converted it from type data frame into a numeric vector. Why does
> this happen, and what can I do about it?

Check parameter "drop" in the documentation of "[" or Extract. The simplification to a vector is default behavior for historical reasons, but somewhat confusing.

Dieter



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 Tue Aug 16 16:35:05 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:22:01 EST