[R-sig-eco] error message when declaring a variable as factor
Mike Marsh
swamp at blarg.net
Sun Sep 5 22:13:49 CEST 2010
Dear R users,
I am using clustering (with hclust) and PERMANOVA (adonis) in R to
compare richness and foliar cover data from two shrub-steppe landscapes
separated by about 5 miles, one grazed (measured with eleven plots) and
the other ungrazed (measured with ten plots) for the last 20 years.
I combined data from two years to increase degrees of freedom, giving me
42 rows.
Environmental data consist of elevation, slope, aspect (as heatload),
E.Site (=environmental "Site" from USGS soil surveys), and "group",
which distinguishes the grazed landscape from the ungrazed one.
I wanted to declare the last two sites as factor, E.Site having 5 levels
and group, of course, having two. Data for both were expressed as
numbers, if that makes a difference.
When I ran the following script I received the error message shown for
group (with levels "1" and "2", but no error for E.Site (with levels 1
to 5).
Wd0709.q0809.richness.env<-as.data.frame(read.table(file.choose(),header=T))
Wd0709.q0809.richness.env$group <-
as.factor(Wd0709.q0809.richness.env$group)
Error in as.vector(x, mode) : invalid 'mode' argument
Wd0709.q0809.richness.env$E.Site <-
as.factor(Wd0709.q0809.richness.env$E.Site)
When I then added group to the adonis equation, the message returned was
"Error in eval(expr, envir, enclos) : object "group" not found".
I repeated the above steps using just the data for the most recent year
(21 rows of data), and two levels, still, for group. No error message
was returned.
Then I re-coded the full environmental data set of 42 rows, separating
the plots into 4 distinct "groups" by year and by landscape treatment.
Again, no error message was returned.
I would like to correct the above error so that I can treat the two
landscapes as just two levels in adonis.
Thanks for any help you can offer.
Mike Marsh
member, Washington Native Plant Society
More information about the R-sig-ecology
mailing list