ps_CV_corr
ps_CV_corr.Rd
Compute coefficients of variation and correlations for specified analytic values, by specified groups, and plots to visualize correlations. Observations with missing values are removed from computations using them.
Usage
ps_CV_corr(
doc = "ps_CV_corr",
data,
GroupVar,
Groups = "All",
ByGroup = TRUE,
ID = " ",
AnalyticVars,
Transpose = TRUE,
CV_digits = 2,
corr_digits = 2,
plotCorrs = TRUE,
folder = " "
)
Arguments
- doc
A string with documentation, default is the function name
- data
AR matrix or data frame containing the data to be analyzedfn
- GroupVar
The name for the variable defining grouping; if " ", no grouping
- Groups
Character valued defining the the groups used_ Options are a Vector of values of the group variable; "All" (the default; use all groups); " ", no grouping
- ByGroup
If TRUE (the default), results are returned for each group in Groups; if FALSE, groups are combined
- ID
The name of a variable with a lab ID (used for sorting data), default is " "
- AnalyticVars
A vector of names (character values) of analytic results
- Transpose
See Details
- CV_digits
The number of significant digits in CV estimates, default is 2
- corr_digits
The number of significant digits in correlation estimates, default is 2
- plotCorrs
Logical, if TRUE (the default), create a matrix of plots describing correlations
- folder
The path to the folder in which data frames will be saved; default is " "
Value
A list with the following components:
usage: A vector with the contents of the argument doc, the date run, the version of R used
dataUsed: The contents of the argument data restricted to the groups used
dataNA: A data frame with observations containing a least one missing value for an analysis variable, NA if no missing values
params: A list containing the values of the grouping,logical, and numeric parameters
analyticVars: A vector with the value of the argument AnalyticVars
CV: A data frame with the coefficients of variation for each analytic variable in each group
corr: A data frame with the correlations between pairs of variables in each group
location: The value of the parameter folder
Details
If Transpose=TRUE, the correlation matrix has rows defined by the group variable and columns defined by the pairs of analytic variables_ If Transpose=FALSE, the rows are defined by pairs of analytic variables and the columns are defined by the groups.
Examples
# All sources combined
data(ObsidianSources)
analyticVars<-c("Rb","Sr","Y","Zr","Nb")
CV_corr<-ps_CV_corr(data = ObsidianSources, GroupVar="Code", Groups = "All",
AnalyticVars=analyticVars, ByGroup=FALSE)
# By source, restricted to two sources
data(ObsidianSources)
analyticVars<-c("Rb","Sr","Y","Zr","Nb")
CV_corr<-ps_CV_corr(data = ObsidianSources, GroupVar="Code", Groups = c("A","B"),
AnalyticVars=analyticVars, ByGroup=TRUE)