| datLUTnm {FIESTA} | R Documentation | 
Data - Gets variable description or class.
Description
Merge a look-up table to append new variables, names, or categories to x.
Usage
datLUTnm(
  xvar,
  x = NULL,
  uniquex = NULL,
  LUT = NULL,
  LUTvar = NULL,
  LUTnewvar = NULL,
  LUTnewvarnm = NULL,
  FIAname = FALSE,
  group = FALSE,
  NAclass = "Other",
  add0 = FALSE,
  spcdname = "COMMON_SCIENTIFIC",
  stopifmiss = FALSE,
  xtxt = NULL,
  dsn = NULL,
  dbconn = NULL,
  dbconnopen = FALSE,
  dbwrite = FALSE,
  dbreturn = TRUE,
  overwrite = TRUE,
  savedata = FALSE,
  savedata_opts = NULL,
  gui = FALSE
)
Arguments
| xvar | String. Name of variable in the data table to join to. | 
| x | Data frame or comma-delimited file (*.csv). The data table with variable to classify. | 
| uniquex | String. Unique values to match, if x is NULL. | 
| LUT | Data frame or comma-delimited file (*.csv). Name of the file with collapsed classes (If FIAname=FALSE). | 
| LUTvar | String. Name of variable in LUT with values matching that xvar. If LUTvar=NULL, LUTvar=xvar. | 
| LUTnewvar | String. Name(s) of other variable(s) in the look-up table to include in join. If NULL, all other variables in table will be included. | 
| LUTnewvarnm | String. Different name(s) for LUTnewvar. If NULL, names will default to LUTnewvar. The length of LUTnewvarnm must equal the length for LUTnewvar. | 
| FIAname | Logical. If TRUE, get FIA reference name based on (ref_codes) within FIESTA. | 
| group | Logical. If TRUE and FIA=TRUE, the group variables in reference table (ref_codes) are merged to data table (GROUPCD, GROUPNM). | 
| NAclass | String. NA values in xvar will be changed to NAclass. | 
| add0 | Logical. IF TRUE, keep all codes in look up table. If FALSE, only include codes that are in x. | 
| spcdname | String. Name for species output type ('COMMON', 'SCIENTIFIC', 'SYMBOL', 'COMMON_SCIENTIFIC'). | 
| stopifmiss | Logical. IF TRUE, stops function if missing codes in LUTx. | 
| xtxt | String.* Name of x table for more useful information in warnings. | 
| dsn | String. Data source name of database with x. | 
| dbconn | Open database connection. | 
| dbconnopen | Logica. If TRUE, keep database connection open. | 
| dbwrite | Logical. If TRUE, write class column to database table x. | 
| dbreturn | Logical. If TRUE, return table with class column. | 
| overwrite | Logical. If TRUE, and the class name already exists in x, overwrites class name. | 
| savedata | Logical. If TRUE, saves 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 = 'datlut'. | 
| gui | Logical. If gui, user is prompted for parameters. | 
Value
| xLUT | The input data table with look-up table variable(s). | 
| xLUTnm | Name of the new variable(s). | 
| LUT | Look up table with categories. | 
If savedata = TRUE, a comma-delimited file is output to the outfolder as outfn. If outfn = NULL, the name of the file will be datlut_'date'.csv.
Note
For available reference tables: sort(unique(ref_codes$VARIABLE))
Author(s)
Tracey S. Frescino
Examples
# Append forest type names using the reference table above.
ref_fortypcd <- ref_codes[ref_codes$VARIABLE == "FORTYPCD",]
WYcondlut <- datLUTnm(WYcond,
                      xvar = "FORTYPCD",
                      LUT = ref_fortypcd,
                      LUTvar = "VALUE",
                      LUTnewvar = "MEANING",
                      LUTnewvarnm = "FORTYPNM")
names(WYcondlut)
WYcond2 <- WYcondlut$xLUT
head(WYcond2[WYcond2$FORTYPCD > 0, ])
# Append forest type names the FIAname parameter. If the xvar is in the stored
# reference table, the name and values will automatically be appended.
WYcondlut2 <- datLUTnm(WYcond,
                       xvar = "FORTYPCD",
                       FIAname = TRUE)
names(WYcondlut2)
WYcond3 <- WYcondlut2$xLUT
head(WYcond3[WYcond3$FORTYPCD > 0, ])