Merge a look-up table to append new variables, names, or categories to x.
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
)
String. Name of variable in the data table to join to.
Data frame or comma-delimited file (*.csv). The data table with variable to classify.
String. Unique values to match, if x is NULL.
Data frame or comma-delimited file (*.csv). Name of the file with collapsed classes (If FIAname=FALSE).
String. Name of variable in LUT with values matching that xvar. If LUTvar=NULL, LUTvar=xvar.
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.
String. Different name(s) for LUTnewvar. If NULL, names will default to LUTnewvar. The length of LUTnewvarnm must equal the length for LUTnewvar.
Logical. If TRUE, get FIA reference name based on (ref_codes) within FIESTA.
Logical. If TRUE and FIA=TRUE, the group variables in reference table (ref_codes) are merged to data table (GROUPCD, GROUPNM).
String. NA values in xvar will be changed to NAclass.
Logical. IF TRUE, keep all codes in look up table. If FALSE, only include codes that are in x.
String. Name for species output type ('COMMON', 'SCIENTIFIC', 'SYMBOL', 'COMMON_SCIENTIFIC').
Logical. IF TRUE, stops function if missing codes in LUTx.
String.* Name of x table for more useful information in warnings.
String. Data source name of database with x.
Open database connection.
Logica. If TRUE, keep database connection open.
Logical. If TRUE, write class column to database table x.
Logical. If TRUE, return table with class column.
Logical. If TRUE, and the class name already exists in x, overwrites class name.
Logical. If TRUE, saves data to outfolder.
List. See help(savedata_options()) for a list of options. Only used when savedata = TRUE. If out_layer = NULL, default = 'datlut'.
Logical. If gui, user is prompted for parameters.
The input data table with look-up table variable(s).
Name of the new variable(s).
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.
For available reference tables: sort(unique(ref_codes$VARIABLE))
# 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)
#> [1] "xLUT" "xLUTnm" "LUT"
WYcond2 <- WYcondlut$xLUT
head(WYcond2[WYcond2$FORTYPCD > 0, ])
#> Key: <FORTYPCD>
#> PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
#> <char> <int> <int> <num> <num>
#> 1: 40404762010690 1 NA 1.00 1.00
#> 2: 40404788010690 1 NA 1.00 1.00
#> 3: 40404943010690 2 NA 0.50 0.50
#> 4: 40404955010690 1 NA 1.00 1.00
#> 5: 40404967010690 2 NA 0.25 0.25
#> 6: 40404970010690 1 NA 0.50 0.50
#> MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
#> <num> <lgcl> <int> <int> <int> <int> <int>
#> 1: 1.00 NA 22 20 0 7 0
#> 2: 1.00 NA 31 30 0 7 0
#> 3: 0.50 NA 46 40 0 7 0
#> 4: 1.00 NA 22 20 0 7 0
#> 5: 0.25 NA 22 20 0 7 0
#> 6: 0.50 NA 46 40 0 7 0
#> ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
#> <int> <int> <int> <int> <int>
#> 1: NA 12 1 NA 182
#> 2: NA 11 1 NA 182
#> 3: NA 11 1 NA 182
#> 4: NA 78 1 NA 182
#> 5: NA 14 1 NA 182
#> 6: NA 15 1 NA 182
#> STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
#> <int> <int> <int> <int> <int> <int> <int> <num>
#> 1: 3 6 4 0 NA 0 NA 180
#> 2: 1 148 5 0 NA 0 NA 180
#> 3: 1 195 5 0 NA 0 NA 180
#> 4: 1 120 3 0 NA 0 NA 180
#> 5: 1 96 5 0 NA 0 NA 180
#> 6: 3 25 5 0 NA 0 NA 180
#> TIMBERCD FORTYPNM
#> <num> <char>
#> 1: 2 Rocky Mountain juniper
#> 2: 2 Rocky Mountain juniper
#> 3: 2 Rocky Mountain juniper
#> 4: 2 Rocky Mountain juniper
#> 5: 2 Rocky Mountain juniper
#> 6: 2 Rocky Mountain juniper
# 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)
#> [1] "xLUT" "xLUTnm" "LUT"
WYcond3 <- WYcondlut2$xLUT
head(WYcond3[WYcond3$FORTYPCD > 0, ])
#> Key: <FORTYPCD>
#> PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
#> <char> <int> <int> <num> <num>
#> 1: 40404762010690 1 NA 1.00 1.00
#> 2: 40404788010690 1 NA 1.00 1.00
#> 3: 40404943010690 2 NA 0.50 0.50
#> 4: 40404955010690 1 NA 1.00 1.00
#> 5: 40404967010690 2 NA 0.25 0.25
#> 6: 40404970010690 1 NA 0.50 0.50
#> MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
#> <num> <lgcl> <int> <int> <int> <int> <int>
#> 1: 1.00 NA 22 20 0 7 0
#> 2: 1.00 NA 31 30 0 7 0
#> 3: 0.50 NA 46 40 0 7 0
#> 4: 1.00 NA 22 20 0 7 0
#> 5: 0.25 NA 22 20 0 7 0
#> 6: 0.50 NA 46 40 0 7 0
#> ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
#> <int> <int> <int> <int> <int>
#> 1: NA 12 1 NA 182
#> 2: NA 11 1 NA 182
#> 3: NA 11 1 NA 182
#> 4: NA 78 1 NA 182
#> 5: NA 14 1 NA 182
#> 6: NA 15 1 NA 182
#> STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
#> <int> <int> <int> <int> <int> <int> <int> <num>
#> 1: 3 6 4 0 NA 0 NA 180
#> 2: 1 148 5 0 NA 0 NA 180
#> 3: 1 195 5 0 NA 0 NA 180
#> 4: 1 120 3 0 NA 0 NA 180
#> 5: 1 96 5 0 NA 0 NA 180
#> 6: 3 25 5 0 NA 0 NA 180
#> TIMBERCD FORTYPNM
#> <num> <char>
#> 1: 2 Rocky Mountain juniper
#> 2: 2 Rocky Mountain juniper
#> 3: 2 Rocky Mountain juniper
#> 4: 2 Rocky Mountain juniper
#> 5: 2 Rocky Mountain juniper
#> 6: 2 Rocky Mountain juniper