[R] Subset by family name?
Ophelia Wang
opheliawang at mail.utexas.edu
Sat Nov 29 11:35:39 CET 2008
Sorry to bother everyone---I realized I should have used "==" instead
of "=" in the subset syntax!
Quoting Ophelia Wang <opheliawang at mail.utexas.edu>:
> 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
>
More information about the R-help
mailing list