|
R SCRIPTName:
If R is not installed on your default path, you can specify it using the SET R PATH command. For example, the following can be used for version 3.6.1 under Windows
On Linux systems, R is typically installed in "/usr/bin" which is in the default path on most systems. So for Linux systems, the SET R PATH command is typically not required. However, if R is not in the default path, you can use the SET R PATH command. On Windows platforms, the RSCRIPT command is equivalent to entering
set system hidden on system <r-path>\rscript.exe <r-script-file> <arg-list> Note that if either the R path or the <r-script-file> contains spaces (and so will be quoted), then "set system hidden" will be set to "off". On Linux platforms, the RSCRIPT command is equivalent to entering
Rscript is a binary front end to R for scripting with R.
where <script-file> contains the name of a file containing an R script; and where <arg-list> is an optional list of arguments to the script.
If Dataplot does not find the R script file, it will search for it in the "scripts" sub-directory in the Dataplot auxiliary directory. Currently (2019/12), there are no R scripts in that directory, although this may change in future releases of Dataplot.
. Step 1: Create the R script using "capture script" . rm rout.txt rout.pdf r_test.r . capture script r_test.r # This is R program file r_test.r 11/4/19 # Purpose: Generate a sequence, square it, and plot it # Date: 11/4/19 # # -----start point----- # x=seq(1,20,length.out=20) y=x^2 both=c(x,y) sink("rout.txt") both sink() jpeg("rout.jpg") plot(x,y) dev.off() end of capture . list r_test.r . . Step 2: Determine if running on Windows or Linux and set R path . let computer = 1 probe iopsy1 if probeval = 1 let computer = 2 end of if . . May need to tweak path for R based on version and . optionally set desired Postscript viewer . if computer = 1 set r path "c:\program files\r\r-3.6.1\bin\" end of if . . Step 3: Run the R script . rscript r_test.r . . Step 4: Display the outputs in Dataplot . list rout.txt . psview rout.jpgThe following output is generated. [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 [26] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Privacy
Policy/Security Notice
NIST is an agency of the U.S.
Commerce Department.
Date created: 12/19/2019 |