internal_desc: General Utility Functions

DBvars.defaultR Documentation

General Utility Functions

Description

These functions provide a wide-range of general utility for a variety of data types. They were developed by the FIESTA development team and solve many general and specific problems for data analysis in R.

Usage

DBvars.default(
  istree = FALSE,
  isseed = FALSE,
  isveg = FALSE,
  isgrm = FALSE,
  isdwm = FALSE,
  issubp = FALSE,
  regionVars = FALSE,
  plotgeom = FALSE,
  regionVarsRS = "RMRS"
)

DBgetfn(
  tab,
  invtype,
  outfn.pre,
  stabbrlst = NULL,
  evalid = NULL,
  qry = FALSE,
  othertxt = NULL,
  outfn.date = FALSE,
  addslash = FALSE,
  ext = "csv",
  outfolder = NULL,
  overwrite = FALSE
)

getspconddat(
  cond = NULL,
  ACTUALcond = NULL,
  cuniqueid = "PLT_CN",
  condid1 = FALSE,
  ACI = FALSE
)

getpfromqry(
  dsn = NULL,
  evalid = NULL,
  plotCur = TRUE,
  pjoinid,
  varCur = "MEASYEAR",
  Endyr = NULL,
  invyrs = NULL,
  allyrs = FALSE,
  SCHEMA. = NULL,
  subcycle99 = NULL,
  designcd1 = FALSE,
  intensity1 = NULL,
  popSURVEY = FALSE,
  chk = FALSE,
  Type = "VOL",
  syntax = "sql",
  plotnm = "plot",
  ppsanm = "pop_plot_stratum_assgn",
  ppsaid = "PLT_CN",
  surveynm = "survey",
  plotobj = NULL,
  dbconn = NULL,
  dbconnopen = TRUE
)

getpwithqry(
  dsn = NULL,
  evalid = NULL,
  states = NULL,
  pjoinid,
  plotCur = FALSE,
  varCur = "MEASYEAR",
  Endyr = NULL,
  invyrs = NULL,
  measyears = NULL,
  allyrs = FALSE,
  SCHEMA. = NULL,
  invtype = "ANNUAL",
  subcycle99 = FALSE,
  designcd1 = FALSE,
  intensity = NULL,
  popSURVEY = FALSE,
  chk = FALSE,
  Type = "VOL",
  syntax = "sql",
  plotnm = "plot",
  ppsanm = "pop_plot_stratum_assgn",
  ppsaid = "PLT_CN",
  surveynm = "survey",
  PLOTdf = NULL,
  pltflds = NULL,
  POP_PLOT_STRATUM_ASSGNdf = NULL,
  ppsaflds = NULL,
  pvars = NULL,
  dbconn = NULL,
  dbconnopen = TRUE,
  withqry2 = FALSE
)

getEvalid.ppsa(
  ppsa,
  states = NULL,
  evalAll = FALSE,
  evalCur = FALSE,
  evalEndyr = NULL,
  evalType = "VOL"
)

getPlotCur(
  pltx,
  Endyr = NULL,
  varCur = "MEASYEAR",
  Endyr.filter = NULL,
  designcd1 = TRUE
)

gui_filterdf(df, byname = TRUE)

DBgetbyids(dbconn, ids, layernm, layerid = "PLT_CN")

DBcreateSQLite(
  SQLitefn = NULL,
  gpkg = FALSE,
  dbconnopen = FALSE,
  outfolder = NULL,
  outfn.pre = NULL,
  outfn.date = FALSE,
  overwrite = FALSE,
  returnpath = TRUE,
  stopifnull = FALSE
)

changeclass(tab, noIDate = TRUE)

customEvalchk(
  states,
  measCur = TRUE,
  measEndyr = NULL,
  measEndyr.filter = NULL,
  allyrs = FALSE,
  invyrs = NULL,
  measyrs = NULL,
  invyrtab = NULL,
  gui = FALSE
)

checkidx(
  dbconn,
  tbl = NULL,
  index_cols = NULL,
  datsource = "sqlite",
  schema = "FS_FIADB",
  dbconnopen = TRUE
)

createidx(dbconn, tbl, index_cols, unique = FALSE, dbconnopen = TRUE)

dbclassify(
  dbconn,
  tabnm,
  classcol,
  cutbreaks,
  cutlabels,
  classnm = NULL,
  overwrite = TRUE,
  NAto0 = FALSE,
  dbconnopen = TRUE,
  quiet = FALSE
)

dbclass(
  dbconn,
  tabnm,
  classcol,
  classvals,
  classlabels,
  classnm = NULL,
  overwrite = TRUE,
  NAto0 = FALSE,
  dbconnopen = TRUE,
  quiet = FALSE
)

getwithqry(
  dsn = NULL,
  evalid = NULL,
  states = NULL,
  pjoinid,
  plotCur = FALSE,
  varCur = "MEASYEAR",
  Endyr = NULL,
  invyrs = NULL,
  measyears = NULL,
  allyrs = FALSE,
  SCHEMA. = NULL,
  invtype = "ANNUAL",
  subcycle99 = FALSE,
  designcd1 = FALSE,
  intensity1 = FALSE,
  popSURVEY = FALSE,
  chk = FALSE,
  Type = "VOL",
  syntax = "sql",
  plotnm = "plot",
  ppsanm = "pop_plot_stratum_assgn",
  ppsaid = "PLT_CN",
  surveynm = "survey",
  PLOTdf = NULL,
  pltflds = NULL,
  POP_PLOT_STRATUM_ASSGNdf = NULL,
  ppsaflds = NULL,
  pvars = NULL,
  dbconn = NULL,
  dbconnopen = TRUE,
  withqry2 = FALSE
)

Ratio2Size(
  yn,
  y2n = NULL,
  yd,
  y2d = NULL,
  ysum,
  dsum,
  uniqueid,
  esttype,
  ratiotype,
  stratalut,
  RHGlut,
  unitvar,
  strvar,
  domain
)

addCI(x, estnm, senm = NULL, conf.level = c(99, 95, 68), gainloss = FALSE)

change10char(xnms)

RtoSQL(filter, x = NULL)

getext(x)

getoutfn(
  outfn,
  outfolder = NULL,
  outfn.pre = NULL,
  outfn.date = FALSE,
  overwrite = FALSE,
  ext = NULL,
  baseonly = FALSE,
  noext = FALSE,
  outfn.default = "outfile",
  add = TRUE,
  append = FALSE,
  gui = FALSE
)

addcommas(vars, ALIAS = NULL, sepchar = ",", quotes = FALSE, paren = FALSE)

pastevars(vars1, vars2, sep = ",")

stopQ()

removecols(x, vars)

DT_NAto0(DT, cols, changeto = 0)

changeNULL(x, xvar, changeto = NULL)

getdups(cx, cuniqueid = "PLT_CN", varnm, fun)

getlistparam(lst)

getnm(xvar, group = FALSE)

capfirst(x, allwords = FALSE)

nbrdecimals(x)

nbrdigits(x)

getfilter(att, val, syntax = "R", quote = FALSE)

filter2qry(filt, layernm)

wraptitle(x, len = 10)

xtabf(x, y, levels)

recodelut(lut, minvar = "min", maxvar = "max", classvar = "class")

findnm(x, xvect, returnNULL = FALSE)

chkdbtab(dbtablst, tab, stopifnull = FALSE)

int64tochar(df)

messagedf(df)

getSPGRPCD(states)

addFORTYPGRPCD(cond)

date2char(df, col, formatstr = "%Y-%m-%d")

getfilter(att, val, syntax = "R", quote = FALSE)

checklevels(x, uniquex, xvar, keepNA = TRUE)

getext(x)

filter2qry(filt, layernm)

recodelut(lut, minvar = "min", maxvar = "max", classvar = "class")

strat.pivot(x, strvar, unitvars, strwtvar = "Prop", strat.levels = NULL)

makedummy(dat, auxlut, predfac)

preds.standardize(plt, aux, prednames)

gregEN.select(
  y,
  x_sample,
  x_pop,
  N,
  alpha = 0.5,
  returncoef = FALSE,
  cvfolds = 10
)

preds.select(y, plt, auxlut, prednames, cvfolds = 10)

fileexistsnm(outfolder, basenm, ext)

getRefcodes(xvar)

getRefobject(xvar)

getadjfactorDWM(
  adj = "samp",
  condx,
  cuniqueid = "PLT_CN",
  condid = "CONDID",
  unitlut = NULL,
  unitvars = NULL,
  strvars = NULL,
  unitarea = NULL,
  areavar = NULL,
  areawt = "SUBP_CONDPROP_UNADJ",
  dwmpropvars = NULL
)

getadjfactorGB(
  condx = NULL,
  treex = NULL,
  seedx = NULL,
  vcondsppx = NULL,
  vcondstrx = NULL,
  cond_dwm_calcx = NULL,
  tuniqueid = "PLT_CN",
  cuniqueid = "PLT_CN",
  vuniqueid = "PLT_CN",
  duniqueid = "PLT_CN",
  condid = "CONDID",
  unitlut = NULL,
  unitvars = NULL,
  strvars = NULL,
  unitarea = NULL,
  areavar = NULL,
  areawt = "CONDPROP_UNADJ",
  cvars2keep = NULL,
  tpropvars = list(SUBP = "SUBPPROP_UNADJ", MICR = "MICRPROP_UNADJ", MACR =
    "MACRPROP_UNADJ")
)

getadjfactorP2VEG(
  adj = "samp",
  condx,
  vcondsppx = NULL,
  vcondstrx = NULL,
  cuniqueid = "PLT_CN",
  vuniqueid = "PLT_CN",
  condid = "CONDID",
  unitlut = NULL,
  unitvars = NULL,
  strvars = NULL,
  unitarea = NULL,
  areavar = NULL,
  areawt = "SUBP_CONDPROP_UNADJ",
  cvars2keep = NULL
)

getadjfactorPLOT(
  condx = NULL,
  treex = NULL,
  seedx = NULL,
  cuniqueid = "PLT_CN",
  tuniqueid = "PLT_CN",
  condid = "CONDID",
  checkNA = TRUE,
  areawt = "CONDPROP_UNADJ",
  tpropvars = list(SUBP = "SUBPPROP_UNADJ", MICR = "MICRPROP_UNADJ", MACR =
    "MACRPROP_UNADJ")
)

getadjfactorVOL(
  adj = adj,
  condx = NULL,
  treex = NULL,
  seedx = NULL,
  tuniqueid = "PLT_CN",
  cuniqueid = "PLT_CN",
  condid = "CONDID",
  unitlut = NULL,
  unitvars = NULL,
  strvars = NULL,
  unitarea = NULL,
  areavar = NULL,
  areawt = "CONDPROP_UNADJ",
  cvars2keep = NULL,
  cpropvars = list(SUBP = "SUBPPROP_UNADJ", MACR = "MACRPROP_UNADJ"),
  tpropvars = list(SUBP = "SUBPPROP_UNADJ", MACR = "MACRPROP_UNADJ", MICR =
    "MICRPROP_UNADJ"),
  keepadjvars = FALSE,
  adjvars = NULL
)

getfunnm(x)

getlt10char(dbname)

getrhat(x)

groupEstunit(x, minplotnum)

groupStrata(x, minplotnum, nvar = "n.strata")

groupUnits(
  tabest,
  domain,
  esttype = "AREA",
  estncol = "estn",
  estncol.var = "estn.var",
  estdcol = "estd",
  estdcol.var = "estd.var",
  covarcol = "covar",
  grpfun = sum,
  domvar2 = NULL,
  rowgrpnm = NULL,
  unitvar = NULL,
  areavar = NULL,
  phototype = "PCT",
  photoratio = FALSE,
  keepvars = NULL
)

getjoinqry(joinid1, joinid2, alias1 = "p.", alias2 = "plta.")

classqry(classcol, fromval, toval, classnm = NULL, NAto0 = TRUE)

classifyqry(
  classcol,
  cutbreaks,
  cutlabels = NULL,
  classnm = NULL,
  NAto0 = FALSE
)

save1tab(
  tab,
  tab.title = NULL,
  outfolder,
  allin1 = TRUE,
  coltitlerow = TRUE,
  coltitle = NULL,
  addtitle = TRUE,
  rowtotal = TRUE,
  rnames = NULL,
  outfn = NULL,
  addformat = TRUE,
  charvars = NULL,
  outfn.date = TRUE,
  overwrite = FALSE,
  cols2format = NULL
)

save2tabs(
  tab1,
  tab2,
  tab1.title,
  tab2.title,
  outfolder,
  coltitlerow = TRUE,
  coltitle = NULL,
  addtitle = TRUE,
  rowtotal = TRUE,
  rnames = NULL,
  outfn.estpse = NULL,
  outfn.date = TRUE,
  overwrite = FALSE
)

strat.collapse(
  stratacnt,
  pltstratx,
  minplotnum.unit = 10,
  minplotnum.strat = 2,
  unitarea,
  areavar,
  unitvar,
  unitvar2 = NULL,
  strvar,
  getwt = FALSE,
  stratcombine = TRUE,
  unitcombine = FALSE,
  vars2combine = NULL,
  ...
)

subpsamp(
  cond,
  subp_cond,
  subplot,
  data_dsn = NULL,
  subpuniqueid = "PLT_CN",
  subpid = "SUBP",
  ACI = FALSE,
  whereqry = NULL
)

subpsampP2VEG(
  plt,
  cond,
  subp_cond,
  subplot,
  data_dsn = NULL,
  subpuniqueid = "PLT_CN",
  subpid = "SUBP",
  ACI = FALSE,
  whereqry = NULL
)

allin1f(
  x,
  y,
  char.width = NULL,
  estnull = "--",
  psenull = "--",
  estround = NULL,
  pseround = NULL
)

crosstabx(
  x,
  xvar,
  estnm,
  psenm,
  allin1 = FALSE,
  char.width = NULL,
  estround = NULL,
  pseround = NULL,
  estnull = "--",
  psenull = "--"
)

add0unit(
  x,
  xvar,
  uniquex,
  unitvar = NULL,
  xvar.add0 = FALSE,
  xvar2 = NULL,
  uniquex2 = NULL,
  xvar2.add0 = FALSE
)

addrowgrp(x, uniquerow, rowvar, rowgrpnm, title.rnames = NULL)

crossxtab(
  group.est,
  rowvar.est = NULL,
  colvar.est = NULL,
  total.est = NULL,
  rowvar,
  colvar,
  estnm,
  psenm,
  estround = NULL,
  pseround = NULL,
  gtotal = TRUE,
  allin1 = FALSE,
  rowgrp = FALSE,
  rowgrpnm = NULL,
  title.rnames = NULL,
  estnull = 0,
  psenull = "--",
  char.width = NULL
)

getdomain()

getestvar()

crossxbyunit(
  unit = NULL,
  unit_grpest = NULL,
  unit_rowest = NULL,
  unit_colest = NULL,
  unit_totest = NULL,
  unitvar,
  rowvar,
  colvar,
  estnm,
  psenm,
  allin1,
  char.width,
  estnull,
  psenull,
  estround = NULL,
  pseround = NULL,
  rowgrp = NULL,
  rowgrpnm = NULL,
  title.rnames = NULL,
  numunits,
  savedata,
  addtitle,
  returntitle,
  outfn.estpse,
  title.estpse,
  title.est,
  title.pse,
  title.ref,
  outfolder,
  outfn.date,
  overwrite,
  esttype,
  phototype,
  rnames = NULL,
  title.colvar = NULL,
  title.unitvar = NULL
)

ptdata2sf(
  ptdata,
  crs,
  coords = c(2, 3),
  asSpatial = FALSE,
  stringsAsFactors = FALSE
)

sf2ptdata(ptlayer, id_fld = 1, stringsAsFactors = FALSE)

layerIntersection(
  layer1,
  layer2,
  asSpatial = FALSE,
  dropLowerDimGeom = TRUE,
  stringsAsFactors = FALSE
)

layerUnion(
  layer1,
  layer2,
  asSpatial = FALSE,
  dropLowerDimGeom = TRUE,
  sfColName = "geometry",
  stringsAsFactors = FALSE
)

tabulateIntersections(
  layer1,
  layer1fld,
  layer2,
  layer2fld = NULL,
  stringsAsFactors = FALSE,
  withUnits = FALSE
)

selectByIntersects(
  layer1,
  layer2,
  overlapThreshold = 0,
  thresholdAsPct = TRUE,
  asSpatial = FALSE,
  stringsAsFactors = FALSE
)

layerFromRasterExtent(rasterfile, asSpatial = FALSE)

wtcalc(wtLUT, strvar, acrevar)

wtcalc.unit(wtLUT, strvar, unit, unitvar, acrevar)

Details

These functions provide a wide-range of general utility for a variety of data types.

Value

Object for internal use by other functions in FIESTAutils or other packages used for USDA Forest Service data analysis.

Author(s)

Tracey S. Frescino, Chris Toney, Grayson W. White


FIESTAutils documentation built on May 29, 2024, 4:06 a.m.