[R-sig-Geo] Subsetting dataframe by all factor levels

Rich Shepard r@hep@rd @ending from @ppl-eco@y@@com
Fri Sep 14 19:12:50 CEST 2018


   I need to learn geospatial analyses in R to complement my GIS knowledge.
I've just re-read the subsetting chapter in Hadley's 'Advanced R' without
seeing how to create separate data frames based by extracting all rows for
each site name in the parent data frame in one step. I believe that what I
need to do is create a list of the factor names and feed them to a loop
subsetting each to a new dataframe. Perhaps there's a better way unknown to
me and I need advice, suggestions, and recommendations how to proceed.

   The inclusive data frame has this structure:

str(rainfall)
'data.frame':	113569 obs. of  6 variables:
  $ name    : Factor w/ 58 levels "Blazed Alder",..: 20 20 20 20 20 20 20 ...
  $ easting : num  2370575 2370575 2370575 2370575 2370575 ...
  $ northing: num  199338 199338 199338 199338 199338 ...
  $ elev    : num  228 228 228 228 228 228 228 228 228 228 ...
  $ sampdate: Date, format: "2005-01-01" "2005-01-02" ...
  $ prcp    : num  0.59 0.08 0.1 0 0 0.02 0.05 0.1 0 0.02 ...

   My goal is to use the monthly mean rainfall at each of the 58 reporting
stations to interpolate/extrapolate rainfall over the entire county for
selected years to show variability. The data points are not evenly
distributed but clustered in more populated areas and dispersed in rural
areas. My geochemical data typically are like this and I need to also learn
how this distribution affects how the data are analyzed.

TIA,

Rich



More information about the R-sig-Geo mailing list