[R] error in barplot

Jim Lemon jim at bitwrit.com.au
Fri May 10 03:36:39 CEST 2013


On 05/10/2013 07:22 AM, Carol Van Hulle wrote:
> Hi all,
>
> I am trying to create a barplot for the following data:
>
>   ssmsm, ssaudmn, sstacmn
>   .35, .93, .63
>   1.9, 1.51., 1.8
>   .78, 1.6, 1.24
>   1.10, 1.60, 1.24
>
> I used the following code:
> sd<-read.table("dat.csv", header=T, sep=",")
>
> barplot(as.matrix(sd), main="Figure 1", ylab= "Mean", beside=TRUE, col=rainbow(3))
> legend("topleft", c("low", "chronic", "remitted", "late-onset"), cex=0.6,
>   bty="n", fill=rainbow(3))
>
> But I get the following error:
> Error in -0.01 * height : non-numeric argument to binary operator
>
> I get that sd needs to be a matrix, but I'm not sure why using as.matrix is not good enough. Any suggestions?
>
Hi Carol,
It is probably the extra "." in the value 1.51

Jim



More information about the R-help mailing list