R/rvn_write_Raven_table.R
rvn_write_Raven_table.Rd
Writes a nicely formatted tables of Raven attributes/parameters
rvn_write_Raven_table(
attributes,
units,
df,
filename,
id_col = TRUE,
justify = "right",
sep = ", ",
...
)
array of strings containing attribute/parameter names
array of strings with the corresponding units
Dataframe of values corresponding to attributes/parameters
Name of the file, with extension, to append the table to
TRUE/FALSE
of whether an numeric id column is the first column in the table
and, in common Raven fashion, does not have a corresponding attribute (default TRUE
)
alignment of character columns (default 'right'). See format
character(s) used to seperate columns (default ', ')
Extra arguments for write.fwf
returns TRUE
if executed successfully
soil_classes <- data.frame('Attributes' = c('DEFAULT','ALTERNATIVE'),
'SAND' = c(0.4316, 0.3000),
'CLAY' = c(0.1684, 0.4000),
'SILT' = c(0.4000, 0.3000),
'ORGANIC' = c(0.0000, 0.0000))
attributes <- c('%SAND','%CLAY','%SILT','%ORGANIC')
units <- rep('none',4)
tf <- file.path(tempdir(), "Hogwarts.rvp")
rvn_write_Raven_table(tf, attributes = attributes, units = units, df = soil_classes)
#> [1] TRUE
# view file
readLines(tf)
#> [1] " :Attributes, %SAND, %CLAY, %SILT, %ORGANIC"
#> [2] " :Units , none, none, none, none"
#> [3] " DEFAULT, 0.4316, 0.1684, 0.4, 0"
#> [4] " ALTERNATIVE, 0.3, 0.4, 0.3, 0"