load_mix_data loads the mixture data file and names the biotracers and any Fixed, Random, or Continuous Effects.

load_mix_data(
  filename,
  iso_names,
  factors,
  fac_random,
  fac_nested,
  cont_effects
)

Arguments

filename

csv file with the mixture/consumer data

iso_names

vector of isotope column headings in 'filename'

factors

vector of random/fixed effect column headings in 'filename'. NULL if no factors.

fac_random

vector of TRUE/FALSE, TRUE if factor is random effect, FALSE if fixed effect. NULL if no factors.

fac_nested

vector of TRUE/FALSE, TRUE if factor is nested within the other. Only applies if 2 factors. NULL otherwise.

cont_effects

vector of continuous effect column headings in 'filename'

Value

mix, a list including:

  • mix$data: dataframe, raw mix/consumer data (all columns in 'filename'),

  • mix$data_iso: matrix, mix/consumer biotracer/isotope values (those specified in 'iso_names'),

  • mix$n.iso: integer, number of biotracers/isotopes,

  • mix$n.re: integer, number of random effects,

  • mix$n.ce: integer, number of continuous effects,

  • mix$FAC: list of fixed/random effect values, each of which contains:

    • values: factor, values of the effect for each mix/consumer point

    • levels: numeric vector, total number of values

    • labels: character vector, names for each factor level

    • lookup: numeric vector, if 2 factors and Factor.2 is nested within Factor.1, stores Factor.1 values for each level of Factor.2 (e.g. Wolf Ex has 8 Packs in 3 Regions, and mix$FAC[[2]]$lookup = c(1,1,1,2,2,2,2,3), the Regions each Pack belongs to).

    • re: T/F, is the factor a Random Effect? (FALSE = Fixed Effect)

    • name: character, name of the factor (e.g. "Region")

  • mix$CE: list of length n.ce, contains the cont_effects values centered (subtract the mean) and scaled (divide by SD)

  • mix$CE_orig: list of length n.ce, contains the original (unscaled) cont_effects values

  • mix$CE_center: vector of length n.ce, means of each cont_effects

  • mix$CE_scale: vector of length n.ce, SD of each cont_effects

  • mix$cont_effects: vector of length n.ce, names of each cont_effects

  • mix$MU_names: vector of biotracer/iso MEAN column headings to look for in the source and discrimination files (e.g. 'd13C' in iso_names, 'Meand13C' here)

  • mix$SIG_names: vector of biotracer/iso SD column headings to look for in the source and discrimination files (e.g. 'd13C' in iso_names, 'SDd13C' here)

  • mix$iso_names: vector of isotope column headings in 'filename' (same as input)

  • mix$N: integer, number of mix/consumer data points

  • mix$n.fe: integer, number of Fixed Effects

  • mix$n.effects: integer, number of Fixed Effects + Random Effects

  • mix$factors: vector of length n.effects, names of the Fixed and Random Effects

  • mix$fac_random: T/F vector of length n.effects indicating which effects are Random (= TRUE) and Fixed (= FALSE)

  • mix$fac_nested: T/F vector of length n.effects indicating which effects are nested within the other, if any

  • mix$fere: TRUE if there are 2 Fixed Effects or 1 Fixed Effect and 1 Random Effect, FALSE otherwise. Used by write_JAGS_model.

If no biotracer/isotope columns are specified, a WARNING prompts the user to select 2, 1, or 0.

If more than 2 Fixed/Random Effects are selected, a WARNING prompts the user to select 2, 1, or 0.

If more than 1 Continuous Effect is selected, a WARNING prompts the user to select 1 or 0.