View source: R/isotope-maneuvers.R
| group_birds_by_location | R Documentation | 
This takes as input a data frame of feather isotope data that also has the
isoscape predictions attached to it, just like the data frame returned by
extract_isopredictions.  The data frame must have a column
that gives the general location by which you will group birds for the
rescaling function.  The isoscape predictions by default should be in columns named
iso_pred for the actual prediction, and iso_sd for the standard deviation,
as produced by extract_isopredictions, but those are user configurable,
as well.
group_birds_by_location(
  D,
  feather_isotope_col,
  location_col,
  iso_pred_col = "iso_pred",
  iso_sd_col = "iso_sd"
)
D | 
 the data frame of feather isotope data with the isoscape predictions extracted for each location, as well, and a column giving general grouping locations for the birds.  | 
feather_isotope_col | 
 the string name of the column holding the feather isotope data.  | 
location_col | 
 the string name of the column holding the locations to be used for grouping.  | 
iso_pred_col | 
 name of the column holding the predicted values from the isoscape. Default
is   | 
iso_sd_col | 
 name of the column holding the standard deviations of the predicted values
from the isoscape. Default is   | 
This function returns a data frame with columns for the mean and SD of feather/bird values,
(meanH and sdH) and the mean predicted isotope value and the mean sd of the predicted
isotope values (meaniso and sdiso) for all the samples within each location.  It
also returns the Location column itself and a column cnt that gives the number of bird/tissue
samples from each location.
This function throws an error if any of the locations has only 1 sample. If that is the case, you may consider merging that sample with another location (or dropping it?).
# first run the example for extract_isopredictions to get the variable "x"
example("extract_isopredictions")
# If this were run it gives an error because there is only 1 bird at the
# location "Charlevoix"
## Not run: 
group_birds_by_location(x, feather_isotope_col = "Isotope.Value", location_col = "Location")
## End(Not run)
# remove that one bird at Charlevoix and re-run
y <- x %>%
  dplyr::filter(Location != "Charlevoix")
# then group birds by location
gbl <- group_birds_by_location(D = y,
                               feather_isotope_col = "Isotope.Value",
                               location_col = "Location")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.