setting environment variables programmatically
You can use do.call
to call the function with that named argument:
args = list(var.value)names(args) = var.namedo.call(Sys.setenv, args)
This is a variant of the accepted answer, but if you want to pack this into a single line, and/or avoid generating the intermediate args
object, you can use setNames
to get a named character vector, then coerce to list with as.list
:
do.call(Sys.setenv, as.list(setNames(var.value, var.name)))