Running R function with arguments in 32 bit R, inside 64 bit R -
suppose want run function
test.function <- function(arg1){ print(arg1) } how can run, lets say:
test.function("hello world") in 32 bit mode, using 64 bit r? have managed running entire script in 32 bit mode using
system(paste0(sys.getenv("r_home"), "/bin/i386/rscript.exe ",'"some_script.r"')) but how can change this, can run function arguments, instead of entire script?
edit
following answer roman luštrik , running
system('rscript test.script.r "hello"') gives me following error:
error in windialog(type = "ok", message = message_text) : windialog() cannot used non-interactively call: -> check.for.updates.r -> windialog running stopped
warning message: running command 'rscript test.script.r "hello"' had status 1
(the error message in native language, had translate few words, text might differ on other systems)
you can't run specific function only, have create script. not stop creating one-function script, though.
if create script called test.script.r , put somewhere can find it.
args <- commandargs(trailingonly = true) str(args) test.function <- function(x) { message("your input:") message(x) } invisible(sapply(args, test.function)) open terminal window. can use windows' cmd.exe (press windows key , type cmd.exe or command prompt or whatever have in perhaps localized version of system). navigate script located , run using below command.
$ rscript test.script.r "hello" "hello" "won't tell me name" "i hate doors" chr [1:4] "hello" "hello" "won't tell me name" ... input: hello input: hello input: won't tell me name input: hate doors or, use system same thing through r.
system('rscript test.script.r "hello" "hello" "won't tell me name" "i hate doors"') notice way use single , double quotes. single quotes on outer side. call assumes script located in workspace r looking. can change using setwd(), though.
Comments
Post a Comment