[R] Histogram

Neuro LeSuperHéros neuro3000 at hotmail.com
Wed Apr 20 19:04:08 CEST 2005


As Achim said, I would use a barplot instead of an hist.

Here's how I would do it:

vect<-c("a","b","a","b","b","b","a","a","a")
a<-length(vect[vect=="a"])
b<-length(vect[vect=="b"])
barplot(c(a,b),names.arg=(c("A","B")))

Neuro the Super Hero

>From: "Mag. Ferri Leberl" <ferri.leberl at gmx.at>
>Reply-To: ferri.leberl at gmx.at
>To: r-help at stat.math.ethz.ch
>Subject: [R] Histogram
>Date: Wed, 20 Apr 2005 17:37:04 +0200
>
>Dear everybody!
>I am analysing data from an enquette. The answers are either A or B. How 
>can I
>draw a histogram without transforming the data from characters to numbers? 
>If
>the data are saved in a list M, hist(M[,1]) returns:
>
>Error in hist.default(M[, 1]) : `x' must be numeric
>Execution halted
>
>Thank you in advance!
>
>______________________________________________
>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




More information about the R-help mailing list