[R] Barplots inside loop - several data errors, workaround needed
Jim Holtman
jholtman at gmail.com
Wed May 9 10:30:45 CEST 2012
?try
Sent from my iPad
On May 8, 2012, at 22:03, Lee <muellerl at gmail.com> wrote:
> I have a series of data which is managed through a loop. The loop creates
> "pivot tables" of my data using the *cast* function in the
> *reshape*library. For the most part, the data is all plotted
> correctly.
> Unfortunately, there are a couple of data sets which create errors and halt
> the loop.
>
> One of the tables looks like the following:
>
> dbh Black Walnut
> 1 8 38.19722
> 2 10 48.89244
> 3 12 38.19722
>
> When the loop attempts the barplot() function, the following error is
> returned:
> Error in seq_len(p) : argument must be coercible to non-negative integer
>
> In other cases, there is simply no data in the specified set of data.
> Therefore, the table is full of NA's. Obviously, this does not need to be
> plotted, but I cannot simply remove it from the larger database. I need my
> loop to continue regardless of if it runs into these issues.
>
> *Question: What can I do to ensure the above single variable table will
> plot correctly? and what can I do to suppress errors on the datasets which
> do not have data so the loop continues?*
>
> full code: http://pastebin.com/LB88hpfM
>
> Thank you in advance.
>
> --
> all the best,
> Lee Mueller
> ISA Certified Arborist MI-4148A
> Registered Forester #46043
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
More information about the R-help
mailing list