Miscellaneous snippets for future reference.
Using the jsonlite
package.
library(jsonlite)
<- list(arg1 = "random_arg_value1", arg2 = "random_arg_value2")
json_list <- toJSON(json_list, auto_unbox = TRUE)
json_export write(json_export, "example.json")
The batch file.
set arg1=4
set arg2=experiment_02
"C:\Program Files\R\R-4.1.0\bin\Rscript.exe" C:\path\to\R\script\example_r_script.R %arg% %arg2%
Retrieving arguments in the R script.
args <- commandArgs(trailingOnly = TRUE)
arg1 <- args[1]
arg2 <- args[2]