[R] Boxplots over a Scatterplot

Peter Ehlers ehlers at ucalgary.ca
Thu Jul 8 08:09:32 CEST 2010


On 2010-07-07 18:24, fsch wrote:
>
> I managed to solve the problem myself using:
>
> q=sort(unique(foram$stage[which(foram$length>0)]))
>
>
> boxplot(foram$logl~foram$stage, data=foram, outline=F, at=q, axes=TRUE,
> add=TRUE, col="gray82", medlwd=1)
>
> points(foram$stage,foram$logl, cex=.1)
>
>
> However, for future reference since this was my first post and I was trying
> to give code like you requested, what did I do wrong?

For the benefit of other new useRs: *reproducible* means
that others can plug the code into their R session and
run it. This line in your original post:

  emdata<-read.table(file="#a file in my working directory", sep=",",
  header=T)

can't be run; all of your subsequent code depends on this.

Moreover, *minimal* means that you remove all unnecessary
frills such as specifying colour, x/ylab, main, etc. and
just focus on what you need solved. Use simple names for
your variables. It seems that all too often posters don't
bother to simplify their code. Quite frequently, the
process of simplifying your code will lead you to the
solution you seek. At the very least, it will improve the
chances that someone will look at your problem.

As a new useR, here are two very useful functions to
investigate: dput() and str().

One can also often use built-in datasets or modify
examples from the help pages to illustrate the problem.

It would also be a good thing to acquire the habit of
using TRUE and FALSE instead of T and F.

I'm happy that you've solved your problem yourself. That's
always most satisfying. And don't let my inbred
curmudgeonliness prevent you from asking again when the
need arises.

   -Peter Ehlers



More information about the R-help mailing list