[R] error in barplot

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri May 10 04:10:21 CEST 2013


I am surprised David failed to comment on your choice of variable name. "sd" is an extremely commonly-used function, and defining a variable with that name will make it difficult for you to use that function. "data" is another common function. Some safer options would be "dta" or "sdata". If in doubt, try typing the potential variable name alone at the R input line before defining it yourself. If you get an error, then you shouldn't have a name collision (at least with the core and other packages you have loaded at the time).
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

David Winsemius <dwinsemius at comcast.net> wrote:

>
>On May 9, 2013, at 2:22 PM, 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
>
>Look at str(sd). (It was a data-entry error.)
>> 
>>



More information about the R-help mailing list