rscript

How to run an R script file from the command line

廉价感情. 提交于 2019-12-06 06:23:20
I know there are a lot of questions regarding this issue but I've tried everything and I think I just don't understand how the command line works in windows. I have a file saved in a folder on my desktop, let's say: C:\Users\abika_000\Desktop\R models\myfile.R Here is the directory to my R/bin or Rscript/bin: C:\Program Files\R\R-3.1.0\bin I want to run this code using the cmd prompt. How would I go about doing this? I've tried this solution from the question below but I just keep getting errors no matter what I do: Run R script from command line What I entered: > R CMD BATCH C:\Users\abika

Rscript : Why is Error in UseMethod(“extract_”) : being indicated when attempting to use raster::extract?

徘徊边缘 提交于 2019-12-05 15:08:08
I attempting to use raster package's extract method to extract values from a Raster* object. RStudioPrompt> jpnpe <- extract(jpnp, jpnb, fun = mean, na.rm = T) where jpnp is the raster object and jpnb is SpatialPolygonsDataFrame However the following error is indicated: Error in UseMethod("extract_") : no applicable method for 'extract_' applied to an object of class "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')" How can I get passed this error? Issue may be due to having another package with the same method name, obfuscating the raster extract method. The tidyr package has an

Is it possible to stop `Rscript` cleaning up its `tempdir`?

跟風遠走 提交于 2019-12-05 08:21:33
I'm using R, via Rscript and H2O, but H2O is crashing. I want to review the logs, but the R tempdir that contains them seem to be removed when the R session ends (i.e. when the Rscript finishes). Is it possible to tell R/Rscript not to remove the tmp folder it uses? A work around for this would be to use on.exit to get the temporary files and save them in a different directory. An example function would be like this: ranfunction <- function(){ #Get list of files in tempdir on.exit(templist <- list.files(tempdir(), full.names = T,pattern = "^file") ) #create a new directory for files to go on

Cannot call roxygenize function from Rscript batch file

家住魔仙堡 提交于 2019-12-05 05:31:27
I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason. Here is the code: #!/usr/bin/env Rscript library(roxygen2) roxygenize('.', copy=FALSE) This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly as an executable via Rscript (and I get the error regardless of whether the script is in the current

How to restore RStudio Viewer Pane after having setting its viewer option to NULL?

♀尐吖头ヾ 提交于 2019-12-05 05:16:31
问题 I have set the RStudio Viewer pane to open my default Web Browser instead of the View Pane by setting the following option: options(viewer=NULL) How do I reset back to original setting without starting a new rsession? I want again default to using the Viewer Pane. 回答1: If you have already set the viewer to NULL without preserving your settings, then you will need to copy the viewer setting from a new rsession, but no need to close your current session. 1.The options(viewer=XXXXX) setting is,

Error installing ggplot2

佐手、 提交于 2019-12-04 12:41:52
I was trying to run a simple code on ggplot2 and got the following error: source("u1.txt") Error in library(ggplot2) : there is no package called ‘ggplot2’ Error : package ‘foreign’ was built before R 3.0.0: please re-install it ERROR: lazy loading failed for package ‘maptools’ * removing ‘/home/shivangi/R/i686-pc-linux-gnu-library/3.0/maptools’ * installing *source* package ‘multcomp’ ... ** package ‘multcomp’ successfully unpacked and MD5 sums checked ** R ** data *** moving datasets to lazyload DB ** demo ** inst ** preparing package for lazy loading ** help *** installing help indices **

running an R script from another directory

纵然是瞬间 提交于 2019-12-04 05:27:18
问题 Here's an example with a couple of scripts test.R ==> source("incl.R", chdir=TRUE) print("test.R - main script") incl.R ==> print("incl.R - included") They are both in the same directory. When I run it from that directory using Rscript --vanilla test.R , it works fine. I would like to create multiple subdirectories (run1, run2, run3, ...) and run my original scripts for different parameter values. Suppose I cd run1 and then try to run the script, I get C:\Downloads\scripts\run1>Rscript -

Rscript file path with space

时间秒杀一切 提交于 2019-12-04 03:54:39
问题 I am trying to run the following R script in windows shell: Rscript C:/Documents/Folder name containing space/myscript.txt In this case I get the error: Fatal error: cannot open file 'C:/Documents/Folder': No such file or directory However when I use quotation marks (tried single double and triple as was suggested in other posts) I get the following error: Rscript "C:/Documents/Folder name containing space/myscript.txt" The filename, directory name, or volume label syntax is incorrect. I can

How to pass Rscript -e a multiline string?

假如想象 提交于 2019-12-03 22:56:39
Is there a way to provide the code to Rscript -e in multiple lines? This is possible in vanilla R R --vanilla <<code a <- "hello\n" cat(a) code But using Rscript I get two different things depending on the R version. # R 3.0.2 gives two ignores Rscript -e ' quote> a <- 3+3 quote> cat(a, "\n") quote> ' # ARGUMENT 'cat(a,~+~"' __ignored__ # ARGUMENT '")' __ignored__ Rscript -e 'a <- 3+3;cat(a, "\n")' # ARGUMENT '")' __ignored__ # R 2.15.3 gives an ignore for the multiline, but it works with semicolons Rscript -e ' quote> a <- 3+3 quote> cat(a, "\n") quote> ' # ARGUMENT 'cat(a,~+~"\n")' __ignored

How to restore RStudio Viewer Pane after having setting its viewer option to NULL?

痞子三分冷 提交于 2019-12-03 22:15:51
I have set the RStudio Viewer pane to open my default Web Browser instead of the View Pane by setting the following option: options(viewer=NULL) How do I reset back to original setting without starting a new rsession? I want again default to using the Viewer Pane. If you have already set the viewer to NULL without preserving your settings, then you will need to copy the viewer setting from a new rsession, but no need to close your current session. 1.The options(viewer=XXXXX) setting is, in fact, a function, so open a new ression. 2.Then retrieve the viewer function setting and copy the