Re: [R] Applying function to all elements of a formula

2011-06-19 Thread Scott Fortmann-Roe
Thanks for the tips. I'll give them a try! On Sat, Jun 18, 2011 at 12:07 PM, Dennis Murphy djmu...@gmail.com wrote: Much better..nice! Dennis On Sat, Jun 18, 2011 at 1:53 AM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: maybe another way is by reconstructing the formula using

[R] Applying function to all elements of a formula

2011-06-18 Thread Scott Fortmann-Roe
Hi, I would like to do a regression like: reg - lm(y~log(.), data) where the log function is applied to . in the form: log(x1)+ log(x2)+ log(x3)... instead of in the form log(x1+x2+x3+...) Is this possible? Thank you, Scott [[alternative HTML version

Re: [R] Applying function to all elements of a formula

2011-06-18 Thread Dennis Murphy
Yes, it's possible, but if you want to do prediction on future x-values, you will likely have a problem. One way to do it would be something like (assuming y is the first column of dat) reg - lm(y ~ log(as.matrix(dat[, -1])), dat) but the output would be pretty ugly (see summary(reg)). Another

Re: [R] Applying function to all elements of a formula

2011-06-18 Thread Dimitris Rizopoulos
maybe another way is by reconstructing the formula using paste(), e.g., data - data.frame(y = rnorm(5), x1 = runif(5), z = runif(5), age = runif(5)) nameRsp - y nams - names(data) namsX - nams[!nams %in% nameRsp] form - as.formula(paste(nameRsp, ~ , paste(log(, namsX, ), sep = ,

Re: [R] Applying function to all elements of a formula

2011-06-18 Thread Dennis Murphy
Much better..nice! Dennis On Sat, Jun 18, 2011 at 1:53 AM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: maybe another way is by reconstructing the formula using paste(), e.g., data - data.frame(y = rnorm(5), x1 = runif(5),    z = runif(5), age = runif(5)) nameRsp - y nams -