[R] Subset by string name?

From: Ophelia Wang <opheliawang_at_mail.utexas.edu>
Date: Sat, 29 Nov 2008 04:22:18 -0600


Hi all,

I thought this should be very simple, but I'm not sure where the problem is. I have a .txt data file that contains X and Y coordinates of trees and their family names:

"X" "Y" "Mark"

0	28	"Sapotaceae"
1	30	"Meliaceae"
1	40	"Meliaceae"
1	60	"Mimosaceae"
1	76	"Olacaceae"
1.5	73	"Myristicaceae"
2	34	"Euphorbiaceae"
2	62	"Olacaceae"
2	86	"Mimosaceae"
2.5	36	"Arecaceae"
3	22	"Nyctaginaceae"
3	25	"Moraceae"
3	38	"Rubiaceae"
3	47	"Desconocido "
3	99	"Mimosaceae"
3.5	24	"Anacardiaceae"
3.5	57	"Sapotaceae"
4	1	"Lecythidaceae"

Now I just want to work on one family for various spatial analyses in ads and spatstats, so I wrote:

Yut <-read.delim(
"C:/dissertation/data2006/Parcela_1-3/Yutsun_tree.txt", header = TRUE,
sep = "\t", quote="\"", dec=".", fill = TRUE )

Yut_are <- subset (Yut, Mark="Arecaceae", select=c(X, Y, Mark))

However, the summary of Yut_are still contains trees of other families:

    X                Y                    Mark
   Min.   :  0.00   Min.   : 0.00   Myristicaceae: 65
   1st Qu.: 24.00   1st Qu.:24.00   Lecythidaceae: 60
   Median : 46.00   Median :51.00   Sapotaceae   : 51
   Mean   : 48.07   Mean   :49.72   Moraceae     : 45
   3rd Qu.: 72.50   3rd Qu.:75.50   Arecaceae    : 41
   Max.   :100.00   Max.   :99.00   Mimosaceae   : 34
                                    (Other)      :313

Please tell me how do I subset a dataset like this to extract trees from only one or a few families? Thanks a lot!

Ophelia

-- 
Yung-Ho (Ophelia) Wang
Doctoral Candidate
Department of Geography and the Environment
University of Texas
+1-512-232-1597
opheliawang_at_mail.utexas.edu

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 29 Nov 2008 - 10:26:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 29 Nov 2008 - 15:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive