Paul Menzel
2011-Jul-27 19:30 UTC
[R] ?plot: Add an example on how to plot functions to the help of `plot`.
Dear R folks, currently the section Examples contains the following as an example on how to plot a ?normal? function. plot(sin, -pi, 2*pi) Since it does not contain the argument for the function it would be helpful to add for example the following. ## plots the graph of f(x) = x**2 with f(x) ? [1, 10] curve(x**2, 1, 10) ## plots the graph of f(x) = x**3 with f(x) ? [1, 10] and adds it to an already existing plot curve(x**3, 1, 10, add=T) ## plots the graph of f(x) = x**4 connected by lines and adds it to an already existing plot lines(x, x**4, add=T) `curve` and `lines` could be also added to the section See Also. 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/841f31c9/attachment.bin>
Bert Gunter
2011-Jul-27 20:26 UTC
[R] ?plot: Add an example on how to plot functions to the help of `plot`.
Paul: No such change is needed. You do not understand S3 methods. See ?plot.default and read about S3 methods (e.g. in the tutorial Introduction to R or the Language manual). -- Bert On Wed, Jul 27, 2011 at 12:30 PM, Paul Menzel <paulepanter at users.sourceforge.net> wrote:> Dear R folks, > > > currently the section Examples contains the following as an example on > how to plot a ?normal? function. > > ? ? ? ?plot(sin, -pi, 2*pi) > > Since it does not contain the argument for the function it would be > helpful to add for example the following. > > ? ? ? ?## plots the graph of f(x) = x**2 with f(x) ? [1, 10] > > ? ? ? ?curve(x**2, 1, 10) > > ? ? ? ?## plots the graph of f(x) = x**3 with f(x) ? [1, 10] and adds it to an already existing plot > > ? ? ? ?curve(x**3, 1, 10, add=T) > > ? ? ? ?## plots the graph of f(x) = x**4 connected by lines and adds it to an already existing plot > > ? ? ? ?lines(x, x**4, add=T) > > `curve` and `lines` could be also added to the section See Also. > > > Thanks, > > Paul > > ______________________________________________ > 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. > >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics
Paul Menzel
2011-Jul-27 20:53 UTC
[R] ?plot: Add an example on how to plot functions to the help of `plot`.
Dear Bert, 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. Thanks, Paul [1] http://cran.r-project.org/doc/manuals/R-intro.html -------------- 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/d15b58bf/attachment.bin>
David Winsemius
2011-Jul-27 21:21 UTC
[R] ?plot: Add an example on how to plot functions to the help of `plot`.
On Jul 27, 2011, at 4:53 PM, Paul Menzel wrote:> Dear Bert, > > > 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. -- David Winsemius, MD West Hartford, CT
Apparently Analagous Threads
- Problem with ?curve
- [Bug 69349] New: Random image corruptions (in Debian Wheezy with Linux 3.2)
- How to count numbers of a vector and use them as index values?
- [PATCH] nouveau: fix acpi edid retrieval
- Is R the right choice for simulating first passage times of random walks?