[R] ?plot: Add an example on how to plot functions to the help of `plot`.
Paul Menzel
paulepanter at users.sourceforge.net
Wed Jul 27 23:53:51 CEST 2011
Am Mittwoch, den 27.07.2011, 17:21 -0400 schrieb David Winsemius:
> On Jul 27, 2011, at 4:53 PM, Paul Menzel wrote:
> > Am Mittwoch, den 27.07.2011, 13:26 -0700 schrieb Bert Gunter:
> >> Paul:
> >> No such change is needed.
> >
> > Well the fact is, that I as a beginner was looking for who I could
> > plot normal functions, so one more example would have helped me.
> >
> >> You do not understand S3 methods.
> >
> > That is probably true.
> >
> >> See ?plot.default and read about S3 methods (e.g. in the tutorial
> >> Introduction to R or the Language manual).
> >
> > Searching for »s3 m« in [1] did not give me a good explanation. I have
> > not yet read the language manual.
> >
> > By trial and error I still suggest to add the following.
> >
> > # Plot the graph of a function f(x) = x^3 with the points
> > connected by lines.
> > # If you want to plot the graph as a curve please look into
> > `curve()`.
> > y <- seq(1:5)
> > plot(y, y**3, type="l")
> >
> > This would have helped me as a beginner.
>
> I think that what Bert might have been trying to get you to do was to
> type:
>
> ?plot.function # which is what you might once you do get a better
> understanding S3 methods.
Thank you. So S3 methods seem to be a wrapper for another method. Well I
have to read up about that.
So my newest suggestion is to add a comment to
plot(sin, -pi, 2*pi)
in `?plot`. Like
plot(sin, -pi, 2*pi) # Cf. ?plot.function
as `plot.function` is not explicitly mentioned in `?plot`.
One further comment regarding the examples in `?plot.function`. Trying
those in order
op <- par(mfrow = c(2, 2))
chippy <- function(x) sin(cos(x)*exp(-x/2))
plot (chippy, -8, -5)
for(ll in c("", "x", "y", "xy"))
curve(log(1+x), 1, 100, log = ll,
sub = paste("log= '", ll, "'", sep = ""))
par(op)
I do not see any effect executing `par(op)` at the end. Reading `?par` I
assume it should go before the for loop?
Thanks,
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110727/e23c6287/attachment.bin>
More information about the R-help
mailing list