Thanks, I think it was the odd variable that was named "f.env$zone" I removed 
that column and suddenly things started working

--
Kendra Maas Mitchell, Ph.D.
Post Doctoral Research Fellow
University of British Columbia
604-822-5646
________________________________
From: Dixon, Philip M [STAT] [pdi...@iastate.edu]
Sent: Thursday, December 05, 2013 8:42 AM
To: Mitchell, Kendra
Cc: r-sig-ecology@r-project.org
Subject: NA error in envfit

Kendra,

I wonder if the problem is a factor level with no observations.  One of the 
frustrating things about factors (class variables) in R is that the list of 
levels is stored separately from the data.  This can cause all sorts of 
problems if you create the factor, then subset the data, and the subset is 
missing one or more levels of the factor.  You are subsetting your data, so 
this may be the source of the problem.

My working philosophy is to keep variables as character strings or numbers 
until just before I need the factors.  That avoids any issues with extraneous 
levels.  That means reading data sets (.txt or .csv files) with as.is=TRUE to 
avoid default creation of factors.  relevel() may recreate the list of levels.  
I usually use factor(as.character(variable)) to flip a factor to a vector of 
character strings then back to a factor with the correct set of levels.

Best wishes,
Philip Dixon


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to