FAQ Database Discussion Community


Placing Limits on Optim

r,optimization,regression,rscript
i'm trying to use an algorithm to minimise the least squares of models. I'd like to be able to confine all the parameters to within sensible ranges however when i run this script for whatever reason it is disregarding my limits. More of a debugging issue than anything else. Any...

Running Rscript in command line and loading packages

r,command-line,packages,rscript
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 commandRscript --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...

Rscript: how is $ interpreted in strings passed as inline code

r,special-characters,rscript
Does anyone know how $ is interpreted within an inline call to rscript? In the example below, I am trying to get z to be the "a" element within the x list. However, z=x$a gives me x instead of the element of the list. > Rscript -e "x = list(a=c(1,2,3),...

How to call Rscript from R?

r,testing,rscript
I am developing a package that exposes an R interface (a bunch of functions to be used interactively) and a command line interface via Rscript. This second one works via a small launcher, for instance, at the command line: Rscript mylauncher.R arg1 arg2 arg3 would call a function of my...

Running Rscript via Python using os.system() or subprocess()

python,windows,command-line,rscript
I am facing problems running a Rscript via Python using os.system() or subprocess(). Using os.system() to run commands via python works generally fine for me (e.g. with gdalwarp.exe) but not with Rscript.exe. The only difference I can see are spaces in the path. Avoiding problems with spaces in the path...

R data: Averaging x values into a new vector only if y values are the same

r,data,rscript
I'm relatively new to R and am having trouble processing my data into a more workable form. If I had a continuous x and y vector, some with with multiple x values for the same y value how would I go about writing a script which could automatically average those...

link Rscript to non-existant directory

rscript
I am using program which automatically assumes that Rscript is installed in my home directory. Not even it is not, but the directory /home/username/bin does not even exist - so calling /home/username/bin/Rscript results in an error. However typing "Rscript" works from everywhere. Is there any way how to run Rscript...