add_column_apsim_met | R Documentation |
The usual way of adding a column to a data frame might not work for an object of class ‘met’, so this method is recommended
add_column_apsim_met(met, value, name, units)
## S3 replacement method for class 'met'
x$name <- value
remove_column_apsim_met(met, name)
met |
object of class ‘met’ |
value |
value for the data.frame. It could be an integer, double or vector of length equal to the number of rows in x. |
name |
name of the variable to be removed |
units |
units for the new column (required) |
x |
object of class ‘met’ |
an object of class ‘met’ with the additional column
an object of class ‘met’ without the variable (column) in ‘name’
extd.dir <- system.file("extdata", package = "apsimx")
ames <- read_apsim_met("Ames.met", src.dir = extd.dir)
## The recommended method is
val <- abs(rnorm(nrow(ames), 10))
ames <- add_column_apsim_met(ames, value = val, name = "vp", units = "(hPa)")
## This is also possible
vp <- data.frame(vp = abs(rnorm(nrow(ames), 10)))
attr(vp, "units") <- "(hPa)"
ames$vp <- vp$vp
## This is needed to ensure that units and related attributes are also removed
ames <- remove_column_apsim_met(ames, "vp")
## However, ames$vp <- NULL will also work
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.