Re: [R] Using objects within functions in formulas

2013-01-10 Thread Aidan MacNamara
Thanks everyone, very helpful. On 9 January 2013 18:33, David Winsemius wrote: > > On Jan 9, 2013, at 8:53 AM, Aidan MacNamara wrote: > >> Dear all, >> >> I'm looking to create a formula within a function to pass to glmer() >> and I'm having a problem that the following example will illustrate: >

Re: [R] Using objects within functions in formulas

2013-01-09 Thread Ben Bolker
David Winsemius comcast.net> writes: > On Jan 9, 2013, at 8:53 AM, Aidan MacNamara wrote: > > I'm looking to create a formula within a function to pass to glmer() > > and I'm having a problem that the following example will illustrate: > > > > library(lme4) > > y1 = rnorm(10) > > x1 = data.frame

Re: [R] Using objects within functions in formulas

2013-01-09 Thread David Winsemius
On Jan 9, 2013, at 8:53 AM, Aidan MacNamara wrote: Dear all, I'm looking to create a formula within a function to pass to glmer() and I'm having a problem that the following example will illustrate: library(lme4) y1 = rnorm(10) x1 = data.frame(x11=rnorm(10), x12=rnorm(10), x13=rnorm(10)) x1 =

Re: [R] Using objects within functions in formulas

2013-01-09 Thread Rui Barradas
Hello, Try the following. It uses argument 'data' to pass the data.frame w2. In the function below, I've changed the pastes to two lines of code because the first one changes the way the formula is put together. test1 <- function(x2, y2, w2) { #print(str(w2)) p1 <- paste("(1|", names(