[R] How to get all the data in a specific column from a dataframe?

Chuck Cleland ccleland at optonline.net
Fri Feb 3 17:08:42 CET 2006


test_frame[,"col3"]

or

subset(test_frame, select = col3)

Vincent Deng wrote:
> Dear R-helpers:
> 
> Suppose I have a datafram called "test_frame" like this
>      col1   col2  col3  col4
> r1   x        x        x     x
> r2   x        x        x     x
> r3   x        x        x     x
> ..    x        x        x     x
> rn   x        x        x     x
> 
> I know I can get data of col3 by using test_frame[,3].
> 
> My question is, if I want to do this by specifying "col3" rather than 3,
> what should I do?
> 
> Many thanks....
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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
> 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list