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

From: Ajay Narottam Shah <ajayshah_at_mayin.org>
Date: Tue 16 Aug 2005 - 16:18:17 EST


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 ...

Normally, I know that the notation dataframe[indexes,] gives you a new data frame which is the specified set of rows. But I find:

> str(data[1:10,])

 num [1:10] 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?

-- 
Ajay Shah                                                   Consultant
ajayshah@mayin.org                      Department of Economic Affairs
http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi

______________________________________________
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:23:57 2005

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