Emre Sevinc
2007-Sep-06 06:55 UTC
[R] How to do ANOVA with fractional values and overcome the error: Error in `storage.mode<-`(`*tmp*`, value = "double") : invalid to change the storage mode of a factor
I have exported a CSV file from my EXCEL worksheet and its last column contained decimal values: Subject;Group;Side;Difference;PercentError M3;1;1;; M5;1;1;375;18,75 M8;1;1;250;14,58 M10;1;1;500;12,50 M12;1;1;375;25,00 . . . When I tried to do ANOVA test on it, R complained by givin error:> Anova3LongAuditoryFemaleError.data <- read.csv("C:\\Documents\ and\ Settings\\Administrator\\My Documents\\CogSci\\tez\\Anova3LongAuditoryFemaleError.csv", header = TRUE, sep = ";")> Anova3LongAuditoryFemaleError.aov = aov(PercentError ~ (Group * Side), data = Anova3LongAuditoryFemaleError.data)Error in `storage.mode<-`(`*tmp*`, value = "double") : invalid to change the storage mode of a factor In addition: Warning message: using type="numeric" with a factor response will be ignored in: model.response(mf, "numeric") What must I do in order to make the ANOVA test on these fractional data? Regards. -- Emre Sevinc [[alternative HTML version deleted]]
Prof Brian Ripley
2007-Sep-06 07:43 UTC
[R] How to do ANOVA with fractional values and overcome the error: Error in `storage.mode<-`(`*tmp*`, value = "double") : invalid to change the storage mode of a factor
Your data file has commas as the decimal point. Use read.csv2 for such files. What happened was that PercentError was read as a factor, and you can't do ANOVA on factors. The warning> In addition: Warning message: > using type="numeric" with a factor response will be ignored in: > model.response(mf, "numeric")told you and us this quite explicitly. If you get an error, also look at the warnings which may well (as here) tell you what precipitated the error. On Thu, 6 Sep 2007, Emre Sevinc wrote:> I have exported a CSV file from my EXCEL worksheet and its last column contained decimal values: > > Subject;Group;Side;Difference;PercentError > M3;1;1;; > M5;1;1;375;18,75 > M8;1;1;250;14,58 > M10;1;1;500;12,50 > M12;1;1;375;25,00 > . > . > . > > > When I tried to do ANOVA test on it, R complained by givin error: > >> Anova3LongAuditoryFemaleError.data <- read.csv("C:\\Documents\ and\ Settings\\Administrator\\My Documents\\CogSci\\tez\\Anova3LongAuditoryFemaleError.csv", header = TRUE, sep = ";") > >> Anova3LongAuditoryFemaleError.aov = aov(PercentError ~ (Group * Side), data = Anova3LongAuditoryFemaleError.data) > > Error in `storage.mode<-`(`*tmp*`, value = "double") : > invalid to change the storage mode of a factor > In addition: Warning message: > using type="numeric" with a factor response will be ignored in: > model.response(mf, "numeric") > > What must I do in order to make the ANOVA test on these fractional data? > > Regards. > > -- > Emre Sevinc > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
(Ted Harding)
2007-Sep-06 08:39 UTC
[R] How to do ANOVA with fractional values and overcome the
On 06-Sep-07 06:55:36, Emre Sevinc wrote:> I have exported a CSV file from my EXCEL worksheet and its last column > contained decimal values: > > Subject;Group;Side;Difference;PercentError > M3;1;1;; > M5;1;1;375;18,75 > M8;1;1;250;14,58 > M10;1;1;500;12,50 > M12;1;1;375;25,00 > . > . > . > > > When I tried to do ANOVA test on it, R complained by givin error: > >> Anova3LongAuditoryFemaleError.data <- read.csv("C:\\Documents\ and\ >> Settings\\Administrator\\My >> Documents\\CogSci\\tez\\Anova3LongAuditoryFemaleError.csv", header >> TRUE, sep = ";")Perhaps you need to specify the "dec" option to read.csv(): read.csv(file, header = TRUE, sep = ",", quote="\"", dec=".", fill = TRUE, ...) i.e. Anova3LongAuditoryFemaleError.data <- read.csv("C:\\Documents\ and\ Settings\\Administrator\\My Documents\\CogSci\\tez\\Anova3LongAuditoryFemaleError.csv", header = TRUE, sep = ";", dec=",") Or else use read.csv2(), where dec = "," is the default. See ?read.csv and read about both read.csv and read.csv2 Otherwise, "18,75" is likely to be treated as text, and not as a numerical value, and so PercetError will be converted into a factor with character-valued levels. Ted.> >> Anova3LongAuditoryFemaleError.aov = aov(PercentError ~ (Group * Side), >> data = Anova3LongAuditoryFemaleError.data) > > Error in `storage.mode<-`(`*tmp*`, value = "double") : > invalid to change the storage mode of a factor > In addition: Warning message: > using type="numeric" with a factor response will be ignored in: > model.response(mf, "numeric") > > What must I do in order to make the ANOVA test on these fractional > data? > > Regards. > > -- > Emre Sevinc > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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.-------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 06-Sep-07 Time: 09:39:04 ------------------------------ XFMail ------------------------------
Maybe Matching Threads
- Help with specifiying random effects in lmer - psychology experiment
- Hint to overcome the problem with animated cursors??
- Unreal Tournament 2003 help - one last bug to overcome!
- to overcome error while computing sd for each subset of data (PR#9931)
- [Beginner] Issue with the barplot function