[R] Error when using anova(lm())

Alison Callahan alison.callahan at gmail.com
Fri Oct 8 18:46:47 CEST 2010


Hello all,

I am trying to perform an ANOVA on some data in a data frame, but when
I try to use lm(), I get the following error:

Error in storage.mode(y) <- "double" :
  invalid to change the storage mode of a factor
In addition: Warning message:
In model.response(mf, "numeric") :
  using type="numeric" with a factor response will be ignored

Here is a subset of my data:

  island_id     refseq_better     total        refseq_proportion
fiveprime   threeprime        island_size
       1a            29                  57          0.508771929824561
    11127     201378               190251
       1c            27                  90               0.3
             6303879    6600994            297115
       1d            33                 115         0.28695652173913
  7001283    7421591            420308
       2b            11                  42          0.261904761904762
  4381375    4520137            138762
       2d            27                  81          0.333333333333333
  5203929    5497271            293342
       3a            44                 141         0.312056737588652
   28792      552044              523252

When I use sapply(dataframe,mode) to check the modes of the columns,
this is my output:

       island_id     refseq_better             total        refseq_proportion
        "numeric"         "numeric"         "numeric"         "numeric"
        fiveprime        threeprime       island_size
        "numeric"         "numeric"         "numeric"

How do I need to change the format of my data frame so that I do not
get the above error?

Thanks!

Alison Callahan
PhD candidate
Department of Biology
Carleton University



More information about the R-help mailing list