Learn R Programming

nichetools (version 0.3.2)

extract_mu: extract \(\mu\)

Description

Extract Bayesian estimates of \(\mu\) from data objects created by nicheROVER or SIBER.

Usage

extract_mu(
  data,
  pkg = NULL,
  isotope_names = NULL,
  data_format = NULL,
  community_df = NULL
)

Value

Returns a tibble of extracted estimates of \(\mu\) created by the function niw.post() or siberMVN() in the packages nicheROVER. and SIBER.

The tibble will contain five columns in the following order, metric, sample_name, sample_number, and the names of the isotope columns supplied to niw.post() or siberMVN() (e.g., d13c and d15n ).

Arguments

data

a list created by the function niw.post() or siberMVN() in the package nicheROVER or SIBER, respectfully.

pkg

a character string that is the name of the package that you're using. Defaults to "nicheROVER". Alternatively the user can supply the argument with "SIBER".

isotope_names

is a vector of character string used change the column name of isotopes used in the analysis. Defaults to c("d13c", "d15n").

data_format

a character string that decides whether the returned object is in long or wide format. Default is "long", with the alternative supplied being "wide".

community_df

a four column data frame. One of the columns has to be named community and the data in the column will be numeric as a character string(e.g., "1", "2", "3"). This is the order of the community names and will be used to join the actual community names to the correct data. These are the same class and values required by the function, createSiberObject() from SIBER. The second column will be the names of the groups that are needed to supply required by the function, createSiberObject() from SIBER. The third and fourth columns contains the actual names of the communities and groups the user is working with (e.g., "region", "common_name").

See Also

nicheROVER::niw.post() and SIBER::siberMVN()

Examples

Run this code
extract_mu(
data = niw_fish_post
)

library(SIBER)

# ---- create community names data frame ----
# uncomment to use
# str(demo.siber.data.2)

demo.siber.data.2$group_name <- as.factor(demo.siber.data.2$group)

demo.siber.data.2$group <- as.numeric(demo.siber.data.2$group_name) |>
as.character()

demo.siber.data.2$community_name <- as.factor(demo.siber.data.2$community)

demo.siber.data.2$community <- as.numeric(demo.siber.data.2$community_name) |>
as.character()

cg_name <- demo.siber.data.2 |>
dplyr::distinct(community, group, community_name, group_name)


extract_mu(
data = post_sam_siber,
pkg = "SIBER",
community_df = cg_name
)

Run the code above in your browser using DataLab