Skip to content

Remove NAs from Barplot

1 message · Doran, Harold

#
Thanks, Marc. It works. My apologies for not making the code
reproducible.  

-----Original Message-----
From: Marc Schwartz (via MN) [mailto:mschwartz at mn.rr.com] 
Sent: Wednesday, August 24, 2005 1:29 PM
To: Doran, Harold
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Remove NAs from Barplot
On Wed, 2005-08-24 at 13:06 -0400, Doran, Harold wrote:
Harold,

Get rid of the 'format(tot)' in your text() call:

text(math.barplot, graph.max+5, tot, xpd = TRUE, 
     col = c("blue", "orange"))


By using format(tot), you are coercing the values to text. Thus:
[,1] [,2] [,3] [,4] [,5] [,6]
math.bar  "NA" "NA" "NA" "NA" "55" "48"
apmxpmeet "47" "50" "49" "50" "49" "46"

versus:
[,1] [,2] [,3] [,4] [,5] [,6]
math.bar    NA   NA   NA   NA   55   48
apmxpmeet   47   50   49   50   49   46


In the first case, text() will draw "NA", whereas in the second, the NA
is ignored.

Also, your code above is not entirely reproducible, since:
Error: Object "tmp" not found


HTH,

Marc Schwartz