Hello world, I'm trying to do an anova on data in data.set, dependent variable is a column named "dep.var", grouping variable is in a column called "indep.var", and is.factor(indep.var) is TRUE... why can't I just do aov(dep.var ~ indep.var, data = data.set)? What have I done to deserve this?! What gives? Am I missing something totlly obvious? R-base-1.0.0-1, linux RH 6.1. ---------------------------------------------------------------------> aov(aggr.resid ~ indiv.code, data = resids.dat)Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function call (arg 4) In addition: Warning message: "-" not meaningful for factors in: Ops.factor(y, offset)> aov(indiv.code ~ aggr.resid, data = resids.dat)Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function call (arg 4) In addition: Warning message: "-" not meaningful for factors in: Ops.factor(y, offset)> resids.datlizard indiv.code aggr.resid 1 L1 1 -0.407454158915762 2 L3 21 1.40911506776508 3 L4 23 1.86473558331119 4 L5 24 -0.090884932234919 5 L6 25 -2.09088493223492 6 L7 26 3.36473558331119 7 L9 27 -0.559327664097794 8 L10 2 0.181304809992027 9 L12 4 -3.05932766409779 10 L13 5 3.94067233590221 11 L16 7 1.68130480999203 12 L17 8 -1.31869519000797 13 L18 9 -2.05932766409779 14 L19 10 2.44067233590221 15 L21 13 -1.66682168482594 16 L22 14 0.0925458410842417 17 L23 15 -2.90745415891576 18 L28 19 1.09254584108424 19 L29 20 -1.90745415891576 20 L1 1 2.36694915254237 21 L2 11 -3.56101694915254 22 L3 21 3.36694915254237 23 L4 23 2.43898305084746 24 L5 24 -0.561016949152542 25 L6 25 -2.56101694915254 26 L7 26 -1.56101694915254 27 L9 27 3.21440677966102 28 L10 2 -1.28559322033898 29 L12 4 -2.03135593220339 30 L13 5 2.21440677966102 31 L15 6 4.21440677966102 32 L16 7 0.714406779661017 33 L17 8 -2.28559322033898 34 L18 9 -3.78559322033898 35 L19 10 0.714406779661017 36 L21 13 -2.51016949152542 37 L22 14 0.489830508474576 38 L23 15 -2.03135593220339 39 L24 16 0.489830508474576 40 L25 17 0.489830508474576 41 L27 18 3.98983050847458 42 L28 19 0.489830508474576 43 L29 20 -3.51016949152542 44 L30 22 0.489830508474576 45 L1 1 -0.272561715904491 46 L2 11 -1.71489275596924 47 L3 21 1.72743828409551 48 L5 24 -0.214892755969243 49 L6 25 0.563941723998381 50 L7 26 0.727438284095508 51 L9 27 6.08316471064346 52 L10 2 -1.01295022258195 53 L12 4 -1.91683528935654 54 L13 5 3.48704977741805 55 L15 6 0.98704977741805 56 L16 7 -1.01295022258195 57 L17 8 -2.51295022258195 58 L18 9 -3.51295022258195 59 L19 10 0.98704977741805 60 L21 13 -0.772561715904492 61 L22 14 -0.436058276001619 62 L23 15 -1.65722379603399 63 L25 17 1.22743828409551 64 L27 18 -1.77256171590449 65 L28 19 1.22743828409551 66 L29 20 -1.43605827600162 67 L30 22 1.22743828409551 68 L1 1 -1.11855317206755 69 L2 11 -2.11855317206755 70 L3 21 2.88144682793245 71 L5 24 -0.118553172067549 72 L6 25 3.04130534002739 73 L7 26 -0.51038338658147 74 L9 27 3.00524874486536 75 L10 2 0.68553172067549 76 L12 4 -1.99475125513464 77 L13 5 3.68553172067549 78 L15 6 -1.81446827932451 79 L16 7 -1.81446827932451 80 L17 8 -3.31446827932451 81 L18 9 0.68553172067549 82 L19 10 2.68553172067549 83 L20 12 -1.54643998174350 84 L21 13 0.953560018256504 85 L22 14 -0.546439981743496 86 L23 15 -1.76277955271565 87 L25 17 0.953560018256504 88 L27 18 -0.458694659972615 89 L29 20 -1.45869465997261 90 L1 1 0.974581939799329 91 L2 11 0.974581939799331 92 L3 21 0.974581939799331 93 L5 24 -1.02541806020067 94 L6 25 -0.723745819397993 95 L7 26 2.97458193979933 96 L9 27 1.46220735785953 97 L10 2 -3.71137123745819 98 L12 4 -0.211371237458194 99 L16 7 -2.21137123745819 100 L17 8 -3.71137123745819 101 L19 10 1.83411371237458 102 L21 13 0.602675585284281 103 L22 14 -2.22374581939799 104 L23 15 -0.665886287625418 105 L24 16 2.60267558528428 106 L25 17 -0.897324414715719 107 L27 18 2.60267558528428 108 L28 19 0.602675585284281 109 L29 20 -0.223745819397993 110 L1 1 0.411073387307392 111 L2 11 1.91107338730739 112 L3 21 2.91107338730739 113 L5 24 0.411073387307391 114 L6 25 -2.08892661269261 115 L7 26 -1.08892661269261 116 L9 27 3.26390702533298 117 L10 2 -2.42713502219901 118 L12 4 -0.427135022199008 119 L13 5 1.57286497780099 120 L16 7 -2.42713502219901 121 L17 8 -3.92713502219901 122 L19 10 1.26390702533299 123 L21 13 -0.265343431705406 124 L22 14 -2.06698876991382 125 L23 15 -1.40519717942021 126 L24 16 1.73465656829459 127 L25 17 1.73465656829459 128 L28 19 1.73465656829459 129 L29 20 -0.912509793679812 130 L30 22 0.087490206320188 131 L1 1 -1.80627454930003 132 L2 11 2.19372545069997 133 L4 23 -0.80627454930003 134 L5 24 0.19372545069997 135 L6 25 -0.607362272132138 136 L7 26 2.19372545069997 137 L9 27 3.02089837848726 138 L10 2 -2.62040487460973 139 L13 5 -0.120404874609729 140 L15 6 -1.62040487460973 141 L16 7 -4.12040487460973 142 L17 8 -0.97910162151274 143 L20 12 -0.0497532480612345 144 L21 13 -0.376926175848525 145 L22 14 -2.04975324806123 146 L23 15 -1.16497129620304 147 L24 16 0.950246751938766 148 L25 17 4.45024675193877 149 L27 18 1.62307382415148 150 L28 19 3.12307382415147 151 L29 20 -1.04975324806123 152 L30 22 -0.376926175848525 153 L1 1 0.786370666909293 154 L2 11 -1.21362933309071 155 L3 21 3.28637066690929 156 L4 23 2.28637066690929 157 L5 24 0.78637066690929 158 L6 25 -1.83823128013829 159 L7 26 -1.21362933309071 160 L9 27 -0.213174415430807 161 L12 4 0.536256937494313 162 L13 5 4.78682558456919 163 L15 6 -3.96374306250569 164 L16 7 0.536256937494313 165 L17 8 -3.96374306250569 166 L18 9 -2.46374306250569 167 L19 10 1.78682558456919 168 L20 12 -2.58811755072332 169 L21 13 1.53648439632427 170 L22 14 0.0364843963242653 171 L23 15 -2.58811755072332 172 L24 16 0.536029478664361 173 L25 17 4.03648439632426 174 L27 18 -1.96351560367573 175 L28 19 2.03602947866436 176 L29 20 -0.963515603675735>----------------------------------------------- -- Pete Hurd phurd at uts.cc.utexas.edu http://www.zo.utexas.edu/research/phurd Section of Integrative Biology, University of Texas, Austin TX 78712 USA -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 31 Mar 2000, Pete Hurd wrote:> I'm trying to do an > anova on data in data.set, dependent variable is a column > named "dep.var", grouping variable is in a column called "indep.var", and > is.factor(indep.var) is TRUE... > why can't I just do aov(dep.var ~ indep.var, data = data.set)? > > What have I done to deserve this?! What gives? Am I missing something > totlly obvious?I think so. In your example it is not obvious what is a factor. I get resids.dat <- read.table("resids") # from output as given aov(aggr.resid ~ factor(indiv.code), data = resids.dat)> summary(.Last.value)Df Sum Sq Mean Sq F value Pr(>F) factor(indiv.code) 25 401.24 16.05 6.5163 4.763e-14 Residuals 150 369.45 2.46 In aov(y ~ x) you should expect x to be a factor and y to be continuous. I think you have made y (aggr.resid) into a factor. That you tried both ways round suggests you are a little confused, and> aov(factor(aggr.resid) ~ factor(indiv.code), data = resids.dat)does give the messages you quoted.> R-base-1.0.0-1, linux RH 6.1.Could you just tell us the version of R? Who packaged it as an RPM is not so relevant.> > --------------------------------------------------------------------- > > > aov(aggr.resid ~ indiv.code, data = resids.dat) > Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function > call (arg 4) > In addition: Warning message: > "-" not meaningful for factors in: Ops.factor(y, offset) > > aov(indiv.code ~ aggr.resid, data = resids.dat) > Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function > call (arg 4) > In addition: Warning message: > "-" not meaningful for factors in: Ops.factor(y, offset)[ ... listing of data ] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._