Re: [R] Simple question on eval

2010-12-01 Thread Joshua Wiley
Here are two options that might work for you given the little bit you've said: ## If its the same parameter all 30 times ## say, for example, base = 4.5 to log for(i in 1:30) { print(log(1:10, base = 4.5)) } ## if they are different parameters, you could try lapply(X = c(1.3, 3, 2.2, 4, 5), FUN

Re: [R] Simple question on eval

2010-12-01 Thread Ivan Calandra
Isn't it what do.call() does? Ivan Le 12/1/2010 16:39, Lamke a écrit : Thank you so much Joshua. That's exactly what I am looking for. What I wanted to do is to pass a parameter to a function and I have to run the functions 30 times. Instead of typing them all out, I created a long string of

Re: [R] Simple question on eval

2010-12-01 Thread Lamke
Thank you so much Joshua. That's exactly what I am looking for. What I wanted to do is to pass a parameter to a function and I have to run the functions 30 times. Instead of typing them all out, I created a long string of "f(a);f(b);f(c) ..." using paste() and use eval and parse to evaluative t

Re: [R] Simple question on eval

2010-11-30 Thread Joshua Wiley
Hi Kel, Try this: eval(parse(text = a)) x Many times (though certainly not all), it may be easier/cleaner to rethink what you are doing (the step before you get a <- "x <- 2^2") to see if there is a simpler way. Cheers, Josh On Tue, Nov 30, 2010 at 2:24 PM, Lamke wrote: > > Hi group, > > I d

[R] Simple question on eval

2010-11-30 Thread Lamke
Hi group, I did some searches about this very simple question. Hope someone can help me out. If I have the following: a <- "x <- 2^2" a [1] "x <- 2^2" How do I evaluate the expression that gets me an answer of 4? I tried the following: > eval(a) [1] "x <- 2^2" > get(a) Error in get(a) : obj