Run R script from command line -
i have file, called a.r, has chmod of 755,
sayhello <- function(){ print('hello') } sayhello() how can run via command-line?
if want output print terminal best utilize rscript
rscript a.r note when using r cmd batch a.r instead of redirecting output standard out , displaying on terminal new file called a.rout created.
r cmd batch a.r # check output cat a.rout if want utilize ./a.r way of calling script add together appropriate #! top of script
#!/usr/bin/env rscript sayhello <- function(){ print('hello') } sayhello() r
No comments:
Post a Comment