R/replace_vec_elem.R
replace_vecelements.Rd
Replace elements in a data.frame or vector of length > 1 by name
replace_vecelements(x, varnms, vals)
The vector or data.frame in x with the elements 'varnms' replaced by vals.
soil_materials <- data.frame(ths = rep(0.4,3), alpha = rep(23.1, 3))
varnms = c("soil_materials.ths3", "soil_materials.ths1", "soil_materials.alpha2")
vals = c(0.999, 0.001, 99)
soil_materials
#> ths alpha
#> 1 0.4 23.1
#> 2 0.4 23.1
#> 3 0.4 23.1
replace_vecelements(soil_materials, varnms, vals)
#> alpha ths
#> 1 23.1 0.001
#> 2 99.0 0.400
#> 3 23.1 0.999
x <- set_paramLWFB90()[["pdur"]]
varnms <- c("pdur2", "pdur12")
vals <- c(0,10)
x
#> [1] 4 4 4 4 4 4 4 4 4 4 4 4
replace_vecelements(x, varnms, vals)
#> [1] 4 0 4 4 4 4 4 4 4 4 4 10