0

I'm just asking how to transform from categorical variables to quantitative variables so as to make a boxplot.

My command is:

wiser_perc<-read.csv("Perca_fluviatilis.csv",header=T, sep=";")


attach(wiser_perc)

summary(wiser_perc)

 Country   
Sweden :156
Germany: 73 
France : 67
Norway : 19 
Estonia:  8
(Other):7

Diversity

1,66E+00:  8 
1,28E+00:  6  
1,64E+00:  5  
1,76E+00:  5 
2,01E+00:  5  
2,36E+00:  5

(Other):299

boxplot(Diversity~Country, data=wiser_perc,boxwex=0.7,cex.axis=0.8,ylab="Size diversity")

      Error in boxplot.default(split(mf[[response]], mf[-response]), ...) : 
      adding class "factor" to an invalid object
#

So, I don't know how to change the variable "Diversity" to a quantitative variable.

Please, I'm stuck in that problem.

Rinot
  • 199
  • 2
  • 10
  • 1
    Please edit your question to include the output from `dput(head(wiser_perc))` and you should probably also read [this question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – SlowLearner Oct 02 '13 at 11:05
  • 1
    I think your problem starts before. It looks like you have "," for decimal seperator in your csv-file. So it may help to specify the dec-option in your read.csv-line: wiser_perc<-read.csv("Perca_fluviatilis.csv",header=T, sep=";", dec=",") – Sophia Oct 02 '13 at 11:14

1 Answers1

0

You don't want to be using read.csv(), you should be using read.csv2() instead. The latter is designed to be "used in countries that use a comma as decimal point and a semicolon as field separator". That way you don't need to worry about fixing the mess caused by read.csv().

Have a look at: http://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html

Sam Mason
  • 15,216
  • 1
  • 41
  • 60