[R] extracting from a data.frame

Chuck Cleland ccleland at optonline.net
Fri Jan 28 19:32:50 CET 2005


newdat <- subset(a, a$V3 == "O")

?subset

dax42 wrote:
> Hi,
> 
> I am sorry for this simple question, but... How do I extract something 
> from a data.frame?
> The following is my Problem:
> I have got a dataframe "a" with various columns. One of those columns is 
> called V3 and contains elements of the following levels:
> 
>  > levels(a$V3)
>  [1] "C"   "CA"  "CB"  "CD"  "CD1" "CD2" "CE"  "CE1" "CE2" "CE3" "CG"
> [12] "CG1" "CG2" "CH2" "CZ"  "CZ2" "CZ3" "N"   "ND1" "ND2" "NE"  "NE1"
> [23] "NE2" "NH1" "NH2" "NZ"  "O"   "OD1" "OD2" "OE1" "OE2" "OG"  "OG1"
> [34] "OH"  "OXT" "SD"  "SG"
> 
> Now I would like to get all rows of a, that have the value "O" in V3.
> I tried a lot of different combinations of [... but I couldn't make it.
> 
> Any ideas?
> Thanks a lot!
> Dax.
> 
> ______________________________________________
> 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