Re: [R] barplot error

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 17 Oct 2006 - 15:52:06 GMT

On 10/17/06, Farrel Buchinsky <fjbuch@gmail.com> wrote:
> I created a dataframe called OSA
> here is what it looks like
> no.surgery surgery
> 0 0.4 6.9
> 6 0.2 0.3
>
> I have also attached it as an R data file
>
> I cannot understand why I am getting the following error.
>
> > barplot(OSA)
> Error in barplot.default(OSA) : 'height' must be a vector or a matrix
>
> OSA is a data.frame which means R should see it as a matrix.
> What am I not understanding?

A data.frame is not the same as a matrix.

Try one of these using the builtin BOD data frame:

barplot(as.matrix(BOD))

barplot(data.matrix(BOD))

barplot.data.frame <- function(height, ...) barplot(as.matrix(height), ...) barplot(BOD)



R-help@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. Received on Wed Oct 18 02:14:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 17 Oct 2006 - 16:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.