ps_createData
ps_createData.Rd
Create data frame with data to be analyzed, columns in specified order
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"))
#> $usage
#> [1] "ps_createData Fri Jul 14 06:45:02 2023 R version 4.3.1 (2023-06-16)"
#>
#> $analyticVars
#> [1] "Rb" "Sr" "Y" "Zr" "Nb"
#>
#> $dataOut
#> Group ID Rb Sr Y Zr Nb
#> 1 A A1 121 40 23 110 55
#> 2 A A2 117 43 21 110 53
#> 3 A A3 121 44 24 114 49
#> 4 A A4 116 41 22 112 52
#> 5 A A5 118 43 21 111 55
#> 6 A A6 123 44 25 113 53
#> 7 A A7 117 44 23 108 50
#> 8 A A8 115 54 20 113 40
#> 9 A A9 106 39 21 106 50
#> 10 A A10 113 36 19 107 46
#> 11 A A11 109 42 18 110 51
#> 12 A A12 110 41 20 104 50
#> 13 A A13 116 36 21 107 51
#> 14 A A14 123 38 27 113 56
#> 15 A A15 116 42 23 114 53
#>