[R] Error in rowMeans function

PIKAL Petr petr.pikal at precheza.cz
Mon Oct 15 08:46:52 CEST 2012


Hi

I did not use cfa function, the former poster (Catherine)did and I only advised almost the same as you did.

Regards
Petr


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of yrosseel
> Sent: Monday, October 15, 2012 8:40 AM
> To: r-help at r-project.org
> Subject: Re: [R] Error in rowMeans function
> 
> On 10/15/2012 08:28 AM, PIKAL Petr wrote:
> > Hi
> >
> >
> >> -----Original Message----- From: r-help-bounces at r-project.org
> >> [mailto:r-help-bounces at r- project.org] On Behalf Of Gunsalus,
> >> Catherine Sent: Friday, October 12, 2012 8:52 PM To:
> >> r-help at r-project.org Subject: [R] Error in rowMeans function
> >>
> >> Hello, I am trying to create parcels for a CFA model.  I am trying
> to
> >> average 6 sets of 3 variables each into parcels.  I don't understand
> >> why I am getting an error message as follows: Thanks for your help,
> >> Catherine
> >>
> >>
> >>
> >> atds1par <- rowMeans(semHW1dat1[, c("atds1", "atds2", "atds3")],
> >> na.rm=TRUE)
> >>
> >> atds2par <- rowMeans(semHW1dat1[, c("atds4", "atds5", "atds6")],
> >> na.rm=TRUE)
> >>
> >> atds3par <- rowMeans(semHW1dat1[, c("atds7", "atds8", "atds9")],
> >> na.rm=TRUE)
> >>
> >>
> >>
> >> sgs1par <- rowMeans(semHW1dat1[, c("sgs1", "sgs2", "sgs3")],
> >> na.rm=TRUE)
> >>
> >> sgs2par <- rowMeans(semHW1dat1[, c("sgs4", "sgs5", "sgs6")],
> >> na.rm=TRUE)
> >>
> >> sgs3par <- rowMeans(semHW1dat1[, c("sgs7", "sgs8", "sgs9")],
> >> na.rm=TRUE)
> 
> The cfa() function requires that all variables that are specified in
> the model syntax are included in a data.frame. So after constructing
> your parcels, you need to create a new data.frame containing them:
> 
> Data <- data.frame(ads1par=atds1par, atds2par=atds2par,
> atds3par=atds3par, sgs1par=sgs1par, sgs2par=sgs2par, sgs3par=sgs3par)
> 
> then, you can call the cfa() function but with 'Data' as your data
> argument (note: no need to provide sample.nobs, we get it from the
> data.frame):
> 
> parout1 <- cfa(parmod1, data=Data, std.lv=TRUE)
> 
> Hope this helps,
> 
> Yves
> http://lavaan.org
> 
> ______________________________________________
> 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.




More information about the R-help mailing list