datPivot {FIESTA} | R Documentation |
Data - Generates a pivot table.
Description
Generates a pivot table of values by x row and y column.
Usage
datPivot(
x,
pvar,
xvar,
yvar,
pfun = sum,
xfilter = NULL,
NAto0 = TRUE,
dropNAxvar = TRUE,
dropNAyvar = TRUE,
pvar.round = 6,
returnDT = FALSE,
savedata = FALSE,
savedata_opts = NULL,
gui = FALSE
)
Arguments
x |
Dataframe. Table with pivot variables. |
pvar |
String. The name of the variable for pivot table values. |
xvar |
String. The name of the variable for rows. |
yvar |
String. The name of the variable for columns. |
pfun |
Function. The name of the function to use for pivot table values (ex. sum, mean, max). |
xfilter |
String. A filter to subset the datatable table x before pivoting (ex. "STATUSCD == 1"). |
NAto0 |
Logical. If TRUE, converts NA values to 0. |
dropNAxvar |
Logical. If TRUE, removes columns that are NA. |
dropNAyvar |
Logical. If TRUE, removes rows that have NA values. |
pvar.round |
Integer. Number to round pvar values to. |
returnDT |
Logical. If TRUE, returns a datatable. |
savedata |
Logical. If TRUE, writes output data to outfolder. |
savedata_opts |
List. See help(savedata_options()) for a list of options. Only used when savedata = TRUE. If out_layer = NULL, default = 'datpivot'. |
gui |
Logical. If TRUE, pop-up windows will appear for user-interface. |
Value
ptab |
Matrix. The pivot table. |
Author(s)
Tracey S. Frescino
Examples
# Pivot WYcond table
datPivot(x = FIESTA::WYcond,
pvar = "CONDPROP_UNADJ",
xvar = "FORTYPCD",
yvar = "STDSZCD")
# Pivot WYtree table
datPivot(x = FIESTA::WYtree,
pvar = "TPA_UNADJ",
xvar = "SPCD",
yvar = "STATUSCD",
pfun = mean,
NAto0 = TRUE)