[R] generating a data frame with a subset from another data frame

James R. Milks james.milks at wright.edu
Sun Jul 8 19:08:27 CEST 2007

R gurus,

I have a data set that looks something like this:

Site	Species	DBH	#Vines
G	PLOC	45.9	4
G	ACNE	23.3	1
G	ACNE	12.0	0
G	FRAM	35.9	5
G	AEGL	11.2	2
N	PLOC	77.3	12
N	JUNI	78.6	7
N	ACNE	18.9	1
N	ACNE	15.7	3
N	ACRU	35.5	4
H	ACSA2	24.1	6
H	ULAM	35.2	7

There are 730 individual trees (22 species) from four sites in the  
actual data set.  I would like to create a second data frame that  
contains just the most common species (mainly ACNE, PLOC, ULAM, FRAM,  
and ACSA2).  Here's some of my attempts:

Error: syntax error

Error: syntax error

#This one appeared to work, but upon inspection, it just copied the  
entire "study" data frame instead of just copying the data I wanted,  
as study.1$Species had a length of 22 (the same as the original)  
instead of the desired length of 5.

I've already consulted a book on R as well as spent the last three  
hours searching the R-help archives.  There must be a way to get the  
subset I desire but it is not obvious to me.

Thanks in advance for your help.

Jim Milks

Graduate Student
Environmental Sciences Ph.D. Program
Wright State University
3640 Colonel Glenn Hwy
Dayton, OH 45431

More information about the R-help mailing list