Why when I do a "help(plot)" do I not see anything about parameters such as xlim or ylim? As someone new to R, finding that xlim and ylim even existed wasn't all that easy. Even help.search("xlim") shows nothing once I know xlim exists. I'd like to change the default axes but "help(axis)" isn't that informative about changing the frequency of ticks on the axes. Do people really refer to the x-axis as "1" and the y-axis as "2" as shown in help(axis)? plot(1:4, rnorm(4), axes=FALSE) axis(1, 1:4, LETTERS[1:4]) axis(2) I hadn't a clue what the "1" and "2" meant here without reading additional documentation. And where is the "LETTERS" constant defined and what else is defined there? Are there no common R constants defined somewhere so the axes be defined symbolically? Perhaps AXIS_X = 1, AXIS_Y = 2 would be better than just "1" and "2": plot(1:4, rnorm(4), axes=FALSE) axis(AXIS_X, 1:4, LETTERS[1:4]) axis(AXIS_Y) This would at least provide a clue about what is going on here. Why is R such a graphics rich language and the documentation is so lacking in graphics examples? Why can't the documentation include graphics too so one can study code and graphics at the same time? How do I know the graphics I'm seeing is what it's supposed to look like? I'd rather do more in R than MatLab but I find the R documentation somewhat lacking. I prefer not to read the R source code to find the answers. Thanks for any insight about this. efg [[alternative HTML version deleted]]
On Fri, 2004-06-04 at 12:01, Glynn, Earl wrote:> Why when I do a "help(plot)" do I not see anything about parameters > such as xlim or ylim? As someone new to R, finding that xlim and ylim > even existed wasn't all that easy. Even help.search("xlim") shows > nothing once I know xlim exists. > > I'd like to change the default axes but "help(axis)" isn't that > informative about changing the frequency of ticks on the axes. > > Do people really refer to the x-axis as "1" and the y-axis as "2" as > shown in help(axis)? > > plot(1:4, rnorm(4), axes=FALSE) > axis(1, 1:4, LETTERS[1:4]) > axis(2) > > I hadn't a clue what the "1" and "2" meant here without reading > additional documentation. And where is the "LETTERS" constant defined > and what else is defined there? > > Are there no common R constants defined somewhere so the axes be defined > symbolically? Perhaps AXIS_X = 1, AXIS_Y = 2 would be better than just > "1" and "2": > > plot(1:4, rnorm(4), axes=FALSE) > axis(AXIS_X, 1:4, LETTERS[1:4]) > axis(AXIS_Y) > > This would at least provide a clue about what is going on here. > > Why is R such a graphics rich language and the documentation is so > lacking in graphics examples? Why can't the documentation include > graphics too so one can study code and graphics at the same time? How > do I know the graphics I'm seeing is what it's supposed to look like? > > I'd rather do more in R than MatLab but I find the R documentation > somewhat lacking. I prefer not to read the R source code to find the > answers. > > Thanks for any insight about this. > > efgReading the posting guide, for which there is a link at the bottom of each list e-mail, would be a good place to start. The section on "Further Resources" provides important links. Specifically on graphics: 1. Start by reading chapter 12 in An Introduction to R, which covers graphics basics. 2. V&R's MASS also has an excellent chapter (4) on graphics. 3. There is also an article in R News "R Help Desk" (http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf) that would likely be helpful as well. Reviewing these resources would be crucial to assist your comprehension. I think that you will find the documentation for R to be substantial, if you take the time to properly research it. The posting guide will help get you started in that endeavor. In most cases this obviates any need to review source code, though a critical advantage of R is the ability to do just that when you need to. HTH, Marc Schwartz
On Fri, Jun 04, 2004 at 12:01:25PM -0500, Glynn, Earl wrote:> Why when I do a "help(plot)" do I not see anything about parameters > such as xlim or ylim? As someone new to R, finding that xlim and ylim > even existed wasn't all that easy. Even help.search("xlim") shows > nothing once I know xlim exists.Suppose you want to change the range of x adn y values (that is what xlim and ylim does, but you don't know that yet). You type ?plot and you see no parameter that is directly relevant. However, the help page gives you a couple of directions to go from here: you can check ?par (mentioned in the very first lines) and see a plethora of parameters. You search for "axis" (type /axis in a Linux terminal, or use C-S in Emacs/ESS), and soon you will find 'xaxs' The style of axis interval calculation to be used for the x-axis. Possible values are '"r"', '"i"', '"e"', '"s"', '"d"'. The styles are generally controlled by the range of data or 'xlim', if given. Style '"r"' (regular) first extends So you now know that you need something called "xlim" (and ylim, though that is not mentioned explicitly), but find no further information on this page. Therefore you should follow in another direction from ?plot: the very next one (in See also) is plot.default, which has xlim: the x limits (min,max) of the plot. ylim: the y limits of the plot. Lo and behold.> I'd like to change the default axes but "help(axis)" isn't that > informative about changing the frequency of ticks on the axes.How would you like to change them? This list won't be able to help you unless you tell us.> I hadn't a clue what the "1" and "2" meant here without reading > additional documentation. And where is the "LETTERS" constant defined > and what else is defined there??LETTERS has the answer.> Are there no common R constants defined somewhere so the axes be defined > symbolically? Perhaps AXIS_X = 1, AXIS_Y = 2 would be better than just > "1" and "2": > > plot(1:4, rnorm(4), axes=FALSE) > axis(AXIS_X, 1:4, LETTERS[1:4]) > axis(AXIS_Y) > > This would at least provide a clue about what is going on here.It would also clutter the namespace. Feel free to put AXIS_X <- 1 AXIS_Y <- 2 in your .Rprofile.> Why is R such a graphics rich language and the documentation is so > lacking in graphics examples? Why can't the documentation include > graphics too so one can study code and graphics at the same time? How > do I know the graphics I'm seeing is what it's supposed to look like?Because the documentation is pretty much device independent, you can read in interactively on a terminal, or make HTML of PDF output. Graphics would complicate that. IMHO the idea is worth thinking about, but it might involve a lot of work with little benefits. If you want to see examples and the resulting figures side-by-side, get one of the good books on R (MASS would be a good one, see the homepage). I think that you can buy a lot of good books for the price of Matlab.> I'd rather do more in R than MatLab but I find the R documentation > somewhat lacking. I prefer not to read the R source code to find the > answers.I have been using R for a while, but I never HAD to read the source code of any function to find out anything. On the other hand, reading the sources will teach you a lot about R, as the core functions were written by very good programmers in R. Best, Tamas -- Tam??s K. Papp E-mail: tpapp at axelero.hu Please try to send only (latin-2) plain text, not HTML or other garbage.