Displaying 20 results from an estimated 900 matches similar to: "How do I make this faster?"
2009 Aug 28
1
How to convert a string passed as an argument to a vector?
Hi,
$ cat commandArgs.R
args=commandArgs(trailingOnly=TRUE)
args[1]+10
I have the above code. But the following command line gives me an error. I
am wondering what is the correct way to convert a string to a vector?
$ Rscript commandArgs.R 1:3
> args=commandArgs(trailingOnly=TRUE)
> args[1]+10
Error in args[1] + 10 : non-numeric argument to binary operator
Execution halted
Regards,
Peng
2016 Oct 29
3
pasar argumentos de consola a un script de R que contiene source
Hola.
Tengo un script con la siguiente estructura.
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
source("carga-datos.R")
source("modelo.R")
y quiero llamar a mi script desde consola con
Rscript --vanilla miscript.R datos1.csv
De forma que se guarde como argumento el nombre del fichero que quiero 
cargar y se pase a al script carga-datos.R. El problema es
2010 Feb 07
2
conditioned xyplot, many y variables
The example below creates parallel time-series plots of three different y variables conditioned by a dichotomous factor. In the graphical layout,
 	?       Each y variable inhabits its own row and is plotted on its own distinct scale.
 	?       Each level of the factor has its own column, but within each row the scale is held constant across columns.
 	?       The panels fit tightly (as they do
2015 Jan 29
2
[Q] Get formal arguments of my implemented S4 method
I wish it didn't have to depend on the name '.local'.
Back when I wrote a lot of S4 methods I avoided the auto-generated .local
and named the local function something that made sense so that is was easier
for a user to track down the source of an error.
E.g., define the generic QQQ with numeric and integer methods:
setGeneric("QQQ",
           function(x, ...)NULL)
2011 Mar 14
1
Rscript, hashbang, and arguments
Hi,
I have a bunch of R scripts which have the hash bang !/usr/bin/env Rscript
and I typically run these scripts by passing in some parameters like this:
./nameOfRScript arg1 arg2 ...
I know Rscript has the option to run in --vanilla.  Where exactly do I
insert the --vanilla option?  When I do something like this:
./nameOfRScript --vanilla arg1 arg2 ...
And I try to access the commandArgs,
2015 Jan 29
1
[Q] Get formal arguments of my implemented S4 method
Would we really need the special class or would simply checking the formals
of the method against those of the generic be simple and fast enough?
On Thu, Jan 29, 2015 at 9:41 AM, John Chambers <jmc at r-project.org> wrote:
> I wouldn't want to add more to the current approach; if someone would like
> to devote some time, the much preferable idea IMO would be to replace the
>
2009 Nov 10
1
Is it possible to detect whether running as Rscript?
I would like to write a block of code that runs when a script is being  
run from Rscript, but not to run if the same file is being source()d,  
or submitted via ESS, etc. As a gloss I would like to write a file  
that looks somewhat like:
#!/usr/bin/env Rscript
my.func <- function(...) {
	#do something...
}
if ( #is.running.Rscript# ) {
	do.call(my.func, commandArgs(trailingOnly=TRUE))
}
2009 Oct 21
1
formula and model.frame
Suppose I have the following function
myFun <- function(formula, data){
	f <- formula(formula)
	dat <- model.frame(f, data)
	dat
	}
Applying it with this sample data yields a new dataframe:
qqq <- data.frame(grade = c(3, NA, 3,4,5,5,4,3), score = rnorm(8), idVar = c(1:8))
dat <- myFun(score ~ grade, qqq)
However, what I would like is for the resulting dataframe (dat) to include
2010 Jul 08
5
No space left on device on not full filesystem
Hello,
    We have running lustre 1.8.1 and have met "No space lest on device" 
error when uploading 500 Gb small files (less then 100 Kb each).
The problem seems to  depends on the number of files. If we remove one 
file, we can create one new file, even with Gb size; but if we haven''t 
remove something we can''t create even very little file, as an example 
using touch
2011 Feb 02
0
Problem with getFX function
Hi everyone,
Following this post:
http://r.789695.n4.nabble.com/currency-conversion-function-tt906056.html#a906061
I was trying to run the code:
foo <- function(from, to, date){
      url <- "
http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassic&language=en&value=1
"
      params <-
2014 Jul 01
1
combining data from multiple read.delim() invocations.
Is there a better way to do the following? I have data in a number of tab
delimited files. I am using read.delim() to read them, in a loop. I am
invoking my code on Linux Fedora 20, from the BASH command line, using
Rscript. The code I'm using looks like:
arguments <- commandArgs(trailingOnly=TRUE);
# initialize the capped_data data.frame
capped_data <- data.frame(lpar="NULL",
2009 Oct 14
3
currency conversion function?
Dear all
Is there any R function that would perform currency conversion using
up-to-date exchange rates? I would be looking for a function that
allows to download recent exchange rates (say, from Yahoo!) and then
use these in converting currencies (say, USD to EUR).
I am not sure whether r-sig-finance would be more appropriate, but the
(off-)topic feels general enough to me. Thank you
Liviu
--
2011 Mar 12
3
pass character vector in instrument field of get.hist.quote function
I am new to R so I apologize if my question is trivial. I have not been able
to figure out whether what I want to do is even possible.
I have a data frame of stock ticker symbols which I store into R space from
a txt file as follows:
tickers <- read.csv("stocks.txt", header=FALSE, sep=",") 
tickers <- tickers[1]     / the tickers are stored in the first column 
>
2011 Jul 02
5
%dopar% parallel processing experiment
dear R experts---
I am experimenting with multicore processing, so far with pretty
disappointing results.  Here is my simple example:
A <- 100000
randvalues <- abs(rnorm(A))
minfn <- function( x, i ) { log(abs(x))+x^3+i/A+randvalues[i] } ?## an
arbitrary function
ARGV <- commandArgs(trailingOnly=TRUE)
if (ARGV[1] == "do-onecore") {
  ?library(foreach)
  ?discard <-
2011 Nov 28
1
Running Shell Script with R
I'm having some trouble getting my shell script to work. I've checked out the
Intro to R Manual and a host of other websites, but I still can't get the
script to work when I submit the job to the cluster.
Here is my main R code:
##Load Libraries
##...
## Load Time Data
Args <- commandArgs(trailingOnly = TRUE);
print(Args);
timeDat <- read.flowSet(files=NULL, path=Args[1]);
2006 Mar 28
3
Running text app without X
I'm sure this question comes up waaaay to often in this
list, and I apologize if I've missed the obvious answer.
I did spend the last two hours looking for a solution
and trying various things, but to no avail.
I'm trying to run a command-line app (text-only).  It's a
cross-compiler tool for which we only have Windows binaries.
The app works fine, but when I run it (i.e. to
2010 Nov 26
3
Calling substitute(expr, list(a=1)) when expr <- expression(a+b+c)
# The result I am after is the result after a substitution in an expression, such as
substitute(expression(a+b+c), list(a=1))
expression(1 + b + c)
 # However, the way I want to do it is for a an expression "stored as a variable" as
(expr <- expression(a+b+c))
expression(a + b + c)
 # a) The following does not work
(expr2 <- substitute(expr, list(a=1)))
expr
 # b) - whereas this
2010 Jul 22
1
How do I get rid of list elements where the value is NULL before applying rbind?
Here is the function that makes the data.frames in the list:
funweek <- function(df)
  if (length(df$elapsed_time) > 5) {
    res = fitdist(df$elapsed_time,"exp")
    year = df$sale_year[1]
    sample = df$sale_week[1]
    mid = df$m_id[1]
    estimate = res$estimate
    sd = res$sd
    samplesize = res$n
    loglik = res$loglik
    aic = res$aic
    bic = res$bic
    chisq =
2020 Mar 05
3
Should rint and nearbyint be always constrained?
+cfe-dev as the discussion is now biased toward C standard.
I'm not sure what problem you see here.  In default mode, i.e.
> when there is no "#pragma STDC FENV_ACCESS on" in effect,
> then the compiler can always assume that the default rounding
> mode is in effect.
Well, if #pragma STDC FENV_ACCESS on is not in effect, that means
> that the user has promised that at
2005 Nov 02
2
Bug report on get.hist.quote
> get.hist.quote(instrument="INR/USD", provider="oanda", start="2005-10-20")
trying URL 'http://www.oanda.com/convert/fxhistory?lang=en&date1=10%2F20%2F2005&date=11%2F01%2F2005&date_fmt=us&exch=INR&exch2=&expr=USD&expr2=&margin_fixed=0&&SUBMIT=Get+Table&format=ASCII&redirected=1'
Content type