fvs_make_keyfiles: make keyfiles for each row in the input data frame

View source: R/fvs_make_keyfiles.R

fvs_make_keyfilesR Documentation

make keyfiles for each row in the input data frame

Description

make keyfiles for each row in the input data frame

Usage

fvs_make_keyfiles(
  param_df,
  processing_dir = "c:\\temp\\RForInvt\\fvs",
  path_key_proto = NA,
  key_proto = NA,
  clear_db = T,
  clear_keys = T,
  cluster = NA,
  id = c("plt_id"),
  quotes_db = F
)

Arguments

param_df

parameters substituted into keyfile

processing_dir

where do keyfiles and output data go

path_key_proto

(optional) template key file - e.g. use FVS gui

clear_keys

T/F delete all old key files

cluster

(Optional) parallel cluster object

id

select column to use as id field - column should be present in param_df

quotes_db

T/F - recent versions of FVS variants don't accept quotes around db names in key files

Details

make keyfiles for each row in the input data frame


Revision History

1.0 2021 Oct 15 Created

Author(s)

Jacob Strunk <someone@somewhere.com>

See Also

fvs_run
fvs_keyfile_prototype

Examples


clus1 = parallel::makeCluster(4)

#assume a typical inventory dataset and prepare fvs parameters
stand_data = data.frame(stand=1:10, year=2000:2009)#'
df_params = fvs_protype_params()
df_params[1:nrow(stand_data),]=NA
df_params[,"std_id"] = stand_data$stand
df_params[,"invyr"] = stand_data$year
df_params[,"timint"] = 1
df_params[,"numcycle"] = 1
df_params[,"input_db"] = "c:/temp/fordata.db"
df_params[,"fvs_path"] = "C:/FVSbin/FVSca.exe"
df_params[,"tree_table"] = "fvs_treeinit"
df_params[,"stand_table"] = "fvs_standinit"
df_params

#prepare prototype key file
key_proto = fvs_prototype_keyfile(invyr = "InvYear       2001", notriple=NULL)

#convert prototype key file into series of key files associated with each cn
df_keys = fvs_make_keyfiles(df_params, key_proto = key_proto, cluster = clus1, id="std_id")

#lastly, actually run fvs
fvs_run(df_keys, cluster = clus1, db_merge = "FVS_AllRunsB.db")

parallel::stopCluster(clus1)





jstrunk001/RForInvt documentation built on April 17, 2025, 5:02 p.m.