<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
"S.McClatchie" wrote:
<blockquote TYPE=CITE>Colleagues
<p>(...)
<p>When I try to plot them I get an error due to the NA values, I think:
<p>> barplot(x2,
<br>+
xlab='fish length (SL or TL) cm',
<br>+
ylab='individuals per nm towed', col='black')
<br>Error in plot.window(xlim, ylim, log, asp, ...) :
<br> need finite ylim values
<p>Plot.table gives me the same error and I tried na.rm=TRUE to no effect.
<br>Is this simple to solve? I guess I need to replace the NAs with zeros
in
<br>one of the by attributes?
<p>Help will be appreciated.</blockquote>
<br>
<br>
<br>
<p>I guess it depends on what how you want to consider the NAs.
<br>
<p>One way is just to ignore these unspecified values in the plot.
<br>
<p>>data(warpbreaks)
<br>>attach(warpbreaks)
<br>>warpbreaks$breaks[which(warpbreaks$tension == "L")] <-
NA
<br>> myby <- by(warpbreaks$breaks,tension,sum)
<br>> myby
<br>INDICES: L
<br>[1] NA
<br>------------------------------------------------------------
<br>INDICES: M
<br>[1] 475
<br>------------------------------------------------------------
<br>INDICES: H
<br>[1] 390
<br>> #there must be a more elegant way, so I am looking forward to seeing
the wizardry suggested by a
<br>> #member of the R core development team
<br>>barplot(myby[- which(is.na(myby))])
<br>
<p>Cheers,
<br>
<br>
<br>
<p>Laurent
<br>
<br>
<blockquote TYPE=CITE> </blockquote>
<pre>--
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 <A HREF="http://www.cbs.dtu.dk/laurent">http://www.cbs.dtu.dk/laurent</A></pre>
</html>