[R] Error in rowMeans function

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


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)
> 
> 
> 
> > parmod1 <- "ProDragATT =~ atds1par + atds2par + atds3par
> 
> + SucInSchl =~ sgs1par + sgs2par + sgs3par
> 
> + ProDragAtt~~SucInSchl"

are you sure about =~ and ~~ is valid in specifying formula? I am not avare of cfa but it does not seem to be in accordance with all other formulas i know.

> 
> >
> 
> > parout1 <- cfa(parmod1, data=semHW1dat1, sample.nobs=500,
> std.lv=TRUE)
> 
> Error in getDataFull(data = data, group = group, group.label =
> group.label,  :
> 
>   lavaan ERROR: missing observed variables in dataset: atds1par
> atds2par atds3par sgs1par sgs2par sgs3par ProDragAtt

Are your data semHW1dat1 structured as required by cfa?

Somehow cfa function missed your atds1par and other variables which are outside of data frame. Maybe the function requires them to be included in data frame.

All following errors are due to cfa did not evaluated the model.

Regards
Petr



> 
> > summary(parout1)
> 
> Error in summary(parout1) :
> 
>   error in evaluating the argument 'object' in selecting a method for
> function 'summary': Error: object 'parout1' not found
> 
> > fitMeasures(parout1)
> 
> Error in fitMeasures(parout1) : object 'parout1' not found
> 
> > inspect(parout1, "mi")
> 
> Error in inspect(parout1, "mi") :
> 
>   error in evaluating the argument 'object' in selecting a method for
> function 'inspect': Error: object 'parout1' not found
> 
> >
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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