ps_createData: ps_createData

View source: R/ps_createData.r

ps_createDataR Documentation

ps_createData

Description

Create data frame with data to be analyzed, columns in specified order

Usage

ps_createData(doc = "ps_createData", data, Group, Subset, ID, AnalyticVars)

Arguments

doc

Documentation, default is the function name

data

Data frame containing the data for one group

Group

Character: user-specified grouping code for these data, added to the data set

Subset

Character: name of variable with codes for subsets of samples, " " if no subsets

ID

Character: name of IDs (typically lab IDs) for samples

AnalyticVars

Character vector with names for elements used from the data

Value

A list with the elements:

  • usage: Documentatation, including function name, version of R used, date run)

  • dataUsed: Data used, restricted to the specified group

  • analyticVars: The value of AnalyticVars

  • dataOut: The data frame created by the function, with Group, Subset (if specified), ID, and analytic variables

Details

This function creates a data frame with columns in a specified order. It is useful for combining multiple data frames into one analysis object using rbind(). The name for a specified variable must be the same in each file used in the argument data; a space after a variable name in an excel file imported into R yields the variable name followed by a period.

Examples

# create example data set by restricting to one group, removing column with group code,
# then adding that code back to the data set
data(ObsidianSources)
ps_createData(data = ObsidianSources[(ObsidianSources[,"Code"] == "A"),][,-1],
          Group = "A",
          Subset = " ",
          ID = "ID",
          AnalyticVars = c("Rb","Sr","Y","Zr","Nb"))


benmarwick/karon documentation built on July 29, 2023, 10:11 a.m.