Dear Help-list, I have a dataframe containing 6 variables, 4 of which are 
factors, 2 numeric.  I want to create another factor variable (SitePos) by 
combining 2 existing factors (Site and Position).  I have tried a number of 
approaches based on trolling the R FAQs, various R webpages, etc., none of 
which work.  One approach e.g. Data1$SitePos <- paste(Data1$Site, 
Data1$Position) creates the appropriate "SitePos" values e.g. "CR core" but as 
character values not as a factor.  A linear model run on the updated dataframe 
works but notes that it coerces "SitePos" from character to factor e.g. Model.G 
= lmer(log10(SrCa) ~ SitePos + (1 | Eel), data = Data1) .  The next step of a 
multiple comparison test on the output of the linear model: Model.G.mct = 
glht(Model.G, linfct = mcp(SitePos = "Tukey")) fails because the mct does not 
recognize "SitePos" as a factor and gives error message: "Error in mcp2matrix 
(model, linfct = linfct): Variable(s) 'SitePos' of class 'character' is/are n!
 ot contained as a factor in 'model'.  My final step is outputting the mct 
results:  summary (Model.G.mct, test = adjusted(type = "single-step")).  Any 
suggestions as to how to create a composite factor variable in the dataframe 
that would permit execution of the analysis code would be much appreciated.  I 
am using R version 2.13.0 with packages lme4 and multcomp loaded.  Regards,B 
Jessop
                                          
        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to