rscript

Rscript “there is no package”

可紊 提交于 2019-12-11 11:56:06
问题 I have a script that loads data, processes it, and saves the processed data out. I run it manually without a problem, but it does not work with Rscript. It uses the data.table package, and Rscript cannot find it. I have tried the solution here but get the following error message: Error in eval(expr, envir, enclos) : could not find function ".getNamespace" In addition: Warning message: package ‘data.table’ was built under R version 3.1.1 Error : unable to load R code in package ‘chron’ Error:

Running Rscript in command line and loading packages

邮差的信 提交于 2019-12-11 02:45:03
问题 I have a foo.R file which contains library("ggplot2") cat("Its working") I am trying to run foo.r via the command line using the Rscript command Rscript --default-packages=ggplot2 foo.R and it is giving me the following error: 1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘ggplot2’ 2: package ‘ggplot2’ in options("defaultPackages") was not found Error in library("ggplot2") : there is no package called ‘ggplot2’ Execution

How to invoke script that uses scan() on Windows?

亡梦爱人 提交于 2019-12-10 23:56:31
问题 How to invoke an R script like the following scan() in Windows? When using either R or Rscript , nothing is read. With Rscript or littler (both on Linux) the script works as expected. # Doesn't work because stdin is already redirected R --no-save < test.R # Works on Linux, doesn't on Windows Rscript test.R # Works on Linux, doesn't exist in Windows r test.R Is there any way at all to achieve this without changing the R code? Perhaps related: Why is there no --interactive switch in Windows?

Rscript execution error: No such file or directory

半城伤御伤魂 提交于 2019-12-10 18:35:34
问题 The binary of Rscript is available but when I try to use it I get: Rscript helloworld.r Rscript execution error: No such file or directory If I just do Rscript, it brings the help/usage for it through. R CMD BATCH is working fine. I tried adding shebang lines in the R code at the start but it didn't work. #!/sys_apps_01/R/R-3.2.0/bin/R #!/sys_apps_01/R/R-3.2.0/bin/Rscript 回答1: It's likely this was installed to (configured for) another directory and then moved after installation. Afterwards

Rscript on ubuntu

偶尔善良 提交于 2019-12-09 07:53:28
问题 Where can I install Rscript from? I need to run an R script from a php file using exec. However I need to install Rscript first. 回答1: Search the ubuntu repositories. Have you checked the littler package? 回答2: The main package for R is called r-base. For the scripting and command-line front-end see littler (or r-cran-littler in xenial (16.04LTS) and beyond): sudo apt-get install littler 回答3: The answers posted so far are generally useful, but they don't directly answer the question. I recently

Error using rscript

a 夏天 提交于 2019-12-08 19:36:20
问题 I have a Homebrew version of R installed on my Mac (OS X, El Capitan 10.11.5). I've been using rscript successfully for about two weeks now. However, when I tried to run a script this morning using rscript file.r , I get the following error: /usr/local/Cellar/r/3.3.1/R.framework/Versions/3.3/Resources/bin/R: line 209: /usr/local/Library/ENV/4.3/sed: No such file or directory /usr/local/Cellar/r/3.3.1/R.framework/Versions/3.3/Resources/bin/R: line 209: /usr/local/Library/ENV/4.3/sed: No such

Running R via terminal in Windows and leaving R session open

三世轮回 提交于 2019-12-07 18:40:04
问题 Suppose that I have a R script called test.R , stored at C:\ , with the following content: x <- "Hello Stackoverflowers" print(x) To run it via terminal one could simply call: Rscript C:\test.R And as expected, the result will be: However, what I wonder is whether there is a way to run test.R via Windows console but after that staying within the executed R session instead of closing and going back to the console cursor? That is, staying inside the R session instead of going back, in the image

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

China☆狼群 提交于 2019-12-07 09:46:33
问题 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? 回答1: Issue may be due to

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

给你一囗甜甜゛ 提交于 2019-12-07 03:41:53
问题 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? 回答1: 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

Running R via terminal in Windows and leaving R session open

假装没事ソ 提交于 2019-12-06 09:59:54
Suppose that I have a R script called test.R , stored at C:\ , with the following content: x <- "Hello Stackoverflowers" print(x) To run it via terminal one could simply call: Rscript C:\test.R And as expected, the result will be: However, what I wonder is whether there is a way to run test.R via Windows console but after that staying within the executed R session instead of closing and going back to the console cursor? That is, staying inside the R session instead of going back, in the image above, to C:\R\R-3.4.1\bin> . For instance, when compiling Python code with python.exe I can easily