Angela Radulescu
2009-Jul-30 21:37 UTC
[R] lmer() and "$ operator is invalid for atomic vectors"
Hi all, I am a bit mystified by this error message that I get when I try to apply lmer() to a simple dataset with one between factor (age) and one within factor (item): "$ operator is invalid for atomic vectors" I'll just provide the code, because I don't see where the problem is: library(lme4) options(contrasts=c("contr.helmert","contr.poly")) data read.csv("C:/Users/Angela/Desktop/Summer_at_CDS/aging_JDM_Martine/datasets/lamda.data_07.27.09.csv", header=TRUE) attach(data) new<-data.frame(lamda, age.o_1, Item.l2_2,Subject) new Subject <- factor(Subject) Age <- factor(age.o_1,levels=c("0","1"),labels=c("young","old")) Item <- factor(Item.l2_2,levels=c("1","2"),labels=c("lamda1","lamda2")) new2<-data.frame(lamda, Subject, Age, Item) new2 new3 <- na.omit(new2) new3 new4=as.data.frame(new3)> (lmer.lamda <- lmer(lamda ~ Age*Item + ( 1 | Subject), lamda, data=new4))Error in family$family : $ operator is invalid for atomic vectors Here are the first 25 values of the dataframe lmer() should operate on: lamda Subject Age Item 1 1.6000000 1 old lamda1 2 1.0434783 2 old lamda1 3 0.9600000 3 old lamda1 4 3.4285714 4 old lamda1 5 1.1428571 5 old lamda1 6 2.1818182 6 old lamda1 7 0.9600000 7 old lamda1 8 1.8461538 8 old lamda1 9 2.1818182 9 old lamda1 10 1.8461538 10 old lamda1 11 1.8461538 11 old lamda1 12 1.8461538 12 old lamda1 13 2.6666667 13 old lamda1 14 2.6666667 14 old lamda1 15 1.8461538 15 old lamda1 16 1.0434783 16 old lamda1 17 1.8461538 17 old lamda1 18 2.6666667 18 old lamda1 19 2.6666667 19 old lamda1 20 8.0000000 20 old lamda1 21 1.8461538 21 old lamda1 22 8.0000000 22 old lamda1 23 1.8461538 23 old lamda1 24 2.6666667 24 old lamda1 25 2.1818182 25 old lamda1 Any help would be much appreciated this one. I am in the dark and tried pretty much everything... Many thanks, Angela -- View this message in context: http://www.nabble.com/lmer%28%29-and-%22%24-operator-is-invalid-for-atomic-vectors%22-tp24747770p24747770.html Sent from the R help mailing list archive at Nabble.com.
ONKELINX, Thierry
2009-Jul-31 08:28 UTC
[R] lmer() and "$ operator is invalid for atomic vectors"
Dear Angela, I think you have to omit the last lamba in the lmer code. Is there a reason for putting it there? lmer.lamda <- lmer(lamda ~ Age*Item + ( 1 | Subject), data=new4) HTH, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx at inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -----Oorspronkelijk bericht----- Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Angela Radulescu Verzonden: donderdag 30 juli 2009 23:38 Aan: r-help at r-project.org Onderwerp: [R] lmer() and "$ operator is invalid for atomic vectors" Hi all, I am a bit mystified by this error message that I get when I try to apply lmer() to a simple dataset with one between factor (age) and one within factor (item): "$ operator is invalid for atomic vectors" I'll just provide the code, because I don't see where the problem is: library(lme4) options(contrasts=c("contr.helmert","contr.poly")) data read.csv("C:/Users/Angela/Desktop/Summer_at_CDS/aging_JDM_Martine/datase ts/lamda.data_07.27.09.csv", header=TRUE) attach(data) new<-data.frame(lamda, age.o_1, Item.l2_2,Subject) new Subject <- factor(Subject) Age <- factor(age.o_1,levels=c("0","1"),labels=c("young","old")) Item <- factor(Item.l2_2,levels=c("1","2"),labels=c("lamda1","lamda2")) new2<-data.frame(lamda, Subject, Age, Item) new2 new3 <- na.omit(new2) new3 new4=as.data.frame(new3)> (lmer.lamda <- lmer(lamda ~ Age*Item + ( 1 | Subject), lamda, > data=new4))Error in family$family : $ operator is invalid for atomic vectors Here are the first 25 values of the dataframe lmer() should operate on: lamda Subject Age Item 1 1.6000000 1 old lamda1 2 1.0434783 2 old lamda1 3 0.9600000 3 old lamda1 4 3.4285714 4 old lamda1 5 1.1428571 5 old lamda1 6 2.1818182 6 old lamda1 7 0.9600000 7 old lamda1 8 1.8461538 8 old lamda1 9 2.1818182 9 old lamda1 10 1.8461538 10 old lamda1 11 1.8461538 11 old lamda1 12 1.8461538 12 old lamda1 13 2.6666667 13 old lamda1 14 2.6666667 14 old lamda1 15 1.8461538 15 old lamda1 16 1.0434783 16 old lamda1 17 1.8461538 17 old lamda1 18 2.6666667 18 old lamda1 19 2.6666667 19 old lamda1 20 8.0000000 20 old lamda1 21 1.8461538 21 old lamda1 22 8.0000000 22 old lamda1 23 1.8461538 23 old lamda1 24 2.6666667 24 old lamda1 25 2.1818182 25 old lamda1 Any help would be much appreciated this one. I am in the dark and tried pretty much everything... Many thanks, Angela -- View this message in context: http://www.nabble.com/lmer%28%29-and-%22%24-operator-is-invalid-for-atom ic-vectors%22-tp24747770p24747770.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.