Here is an example: library(nlme) library(lme4) library(MASS) data(petrol)
# a variable for one of the columns in petrol Y.VAR <- "Y" # This works: lmer(get(Y.VAR)~EP +(1|No), data=petrol) # This doesn't: lme(get(Y.VAR)~EP, random= ~1|No, data=petrol) # but this does: lme(Y~EP, random= ~1|No, data=petrol) I'd really like to use the variable... again, this is inside a function. Any idea how to solve this. Thanks for your time and expertise, Chuck chuck.01 wrote > > please note that I edited the original message to say: > >> length(with(new3, perm.score))==length(with(new3, get(TRAIT1))) > [1] TRUE > > > > > > chuck.01 wrote >> >> Hi, >> The following lines of code are inside of a function, where "TRAIT1" is >> a function variable calling a column-name inside of the data.frame >> "new3". >> >> This works just fine: >> >> m2 <- lmer(get(TRAIT1) ~ perm.score + (1|site), data=new3) >> >> but this will not work: >> >> m3 <- lme(get(TRAIT1) ~ perm.score , random= ~1|site, data=new3) >> >> I get the following error: >> >> Error in model.frame.default(formula = ~TRAIT1 + perm.score + site, data >> = list( : >> variable lengths differ (found for 'perm.score') >> >> it seems to be putting TRAIT1 on the left side of the equation, and if I >> am wrong about that, the different lengths from the error is still not >> true: >> >>> length(with(new3, perm.score))==length(with(new3, get(TRAIT1))) >> [1] TRUE >> >> Any ideas on either what is going on, or how I can fix this? >> >> ** I'm not including example data, or function because I am hoping it is >> not needed ** >> Please let me know if I am wrong. >> > -- View this message in context: http://r.789695.n4.nabble.com/problem-with-get-inside-of-lme-tp4629360p4629588.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.