Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed
On Tue, 7 Dec 2010 21:24:27 -0700, Greg Snow greg.s...@imail.org wrote: Sharing LaTeX documents with people using word processors only is no more difficult than giving driving directions to someone who is blindfolded . . . . If you just need basic input or approval then give them a paper version or pdf file and then you make the changes. If they are going to be writing major portions or doing a lot of editing, then using LaTeX without all people understanding it will be a headache. I agree with Greg that asking non-LaTeXers to edit a LaTeX document is asking for trouble. But I haven't found it very difficult to import even major portions of reports from a word processor files to LaTeX -- though it can be a lot of work if there's much math or tabular material involved. I agree with Bill that a new fortune has been generated. __ R-help@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.
Re: [R] Legend symbols mixed char and integer
On Sun, 28 Nov 2010 07:54:43 + (GMT), Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Sat, 27 Nov 2010, Mike Prager wrote: I need to generate a plot with both open and filled circles. It is simple enough, using pch=1 and pch=16. The R pdf graphics output is going into pdftex 1.40.10 (MikTeX 2.8). The R pdf is correct when viewed in other viewers. However, pdftex fills the open circles. I can work around this problem by using pch=o for the open circles. However, that messes up the figure legend. Is it possible to use the pch argument of legend() to specify both a symbol number and a character? I haven't found the way. You don't need to. pch=o is the same as pch=111 (the ASCII number). See ?points. Or is there some known work-around for the pdftex bug? Well, pdftex is not a viewer and does not of itself process PDF inclusions, but see ?pdf and the 'useDingbats' argument. If you really think this is a bug in your LaTeX system, you should report it. But you haven't shown us reproducible code, and similar things have worked for me in the past. Many thanks to Brian R. I obtained the desired plot by using 'useDingbats = FALSE', after switching from 'savePlot' to 'dev.copy2pdf', which allows that argument. Thanks especially for the reference to 'points'. Though I had looked several other places for a mapping of 'pch' to characters, I hadn't thought of looking there. To clarify, I doubt that this is an R bug. The PDF displays wrong only when it goes through pdftex. I am not knowledgable enough about pdf or epstex to trace the error's origin. If it would help anyone, I will attempt later to develop simple reproducible code demonstrating this. -- Mike Prager, NC, USA (Remove pi from email to use) __ R-help@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.
[R] Legend symbols mixed char and integer
Dear Gurus, R 2.11.1 on Windows XP. This is a problem in interaction between R and pdftex. I need to generate a plot with both open and filled circles. It is simple enough, using pch=1 and pch=16. The R pdf graphics output is going into pdftex 1.40.10 (MikTeX 2.8). The R pdf is correct when viewed in other viewers. However, pdftex fills the open circles. I can work around this problem by using pch=o for the open circles. However, that messes up the figure legend. Is it possible to use the pch argument of legend() to specify both a symbol number and a character? I haven't found the way. Or is there some known work-around for the pdftex bug? Thanks! -- Mike Prager, NC, USA __ R-help@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.
Re: [R] 4D Plot
On Thu, 27 May 2010 10:42:54 +0200, Spitzner, Andrea andrea.spitz...@uba.de wrote: Hello, I need some help with a 4D-Plot. I can't offer a lot of help, other than to note that There is code for a 4D plot at the R graphics gallery (I am the author) and perhaps looking at that might help. http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=90 __ R-help@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.
Re: [R] How do you change library location ? (in R under windows XP)
On Fri, 23 Apr 2010 15:22:45 +0300, Tal Galili tal.gal...@gmail.com wrote: Due to the new R 2.11 release, I want to implement Dirk's suggestion herehttp://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r . So for that I am asking - How can I (permanently) change R's library path? (The best solution would be one that can be run from within R) To me, it seemed more straightforward to do this outside R. Just set the environment variable R_LIBS in Windows to something like R_LIBS=c:/R/Library Then, delete your R installation. Install the new version and all desired packages. The add-on packages will be located according to your environment setting, and future updates will not require add-on packages to be copied or reloaded. HTH __ R-help@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.
Re: [R] R and S-Plus: Two programs separated by a common language?
On Thu, 22 Apr 2010 12:00:13 -0700 (PDT), Paul Miller pjmiller...@yahoo.com wrote: I was just wondering if anyone could give me some advice about the wisdom or folly of trying to use both [R and S-Plus]. I suspect that trying to use both will give you heartburn. When I switched from S-Plus to R, the most significant differences (for my purposes) were in graphics. The languages differ in the way they approach graphics, and even where the languages appear the same, interpretation of some parameters (such as cex) can be different. Also, the way data are stored differs considerably. Because S-Plus stores data on disk, while R keeps data in memory, S-Plus can have an edge when analyzing huge data sets. (That reflects my understanding of the situation about 5 or 6 yr ago.) I have gone back to old projects and tried to execute my S-Plus code in R. In general, the code needed minor to major massaging to make that happen, especially when the output was carefully annotated graphs. I would recommend that you concentrate on R, where much active development is taking place. Support from this newsgroup is better than support from most commercial vendors, though perhaps not always as sweet-natured. As noted by others, Revolution R is available with commercial support, if you need it. __ R-help@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.
Re: [R] Upgrading R using the global library folder strategy - what do you think about it?
I think it makes more sense for most users to have a global library (as you call it), rather than put the library under the current installation. I have been doing that for years, and it saves a lot of trouble. When I have helped people learn R, the need to copy the library when updating is a regular source of confusion and questions. Many users are not particularly computer-savvy. Given that, it would seem desirable for the R installation to default to a global library location. __ R-help@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.
Re: [R] Page width figures in Latex
On Mon, 29 Mar 2010 12:21:40 +1100, Jim Lemon j...@bitwrit.com.au wrote: bRotheRs sisteRs, I am once again attempting to learn enough Latex voodoo to get something done, and failing comically. The document RJAuthorguide.pdf mentions that one can get page width figures through the use of the figure* or table* environments, but despite considerable searching through the mail archives and reading Frank Harrell's discussion of Using Latex Figure Environments for Plots until my eyes went on strike, I am nowhere near a solution. Would anyone be kind enough to point me to the Idiot's Guide to Latex Figure Environments? Jim Jim, You need a good book on Latex. I like this one: http://www.amazon.com/Guide-LaTeX-4th-Helmut-Kopka/dp/0321173856/ref=sr_1_4?ie=UTF8s=booksqid=1269833347sr=8-4 The width of the figure is controlled by the \includegraphics statement, not any particular part of the environment specification. That assumes you have loaded the graphicx package. For example, \begin{figure}[!th] \begin{center} \includegraphics[width=\textwidth]{myfig.eps}\\ \end{center} \end{figure}% HTH, Mike __ R-help@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.
Re: [R] A slight trap in read.table/read.csv.
Rolf Turner r.tur...@auckland.ac.nz wrote: I solved the problem by putting in a colClasses argument in my call to read.csv(). But I really think that the read functions are being too clever by half here. If field entries are surrounded by quotes, shouldn't they be left as character? Even if they are all F's and T's? Furthermore using F's and T's to represent TRUE's and FALSE's is bad practice anyway. Since FALSE and TRUE are reserved words it would make sense for the read function to assume that a field is logical if it consists entirely of these words. But T's and F's I don't think so. I would argue that this behaviour should be changed. I can see no downside to such a change. I agree with you, Rolf, that this is horrid behavior. It is such automatic devices that have made people hate (e.g.) Microsoft Word with a passion. Yet, in R this is a designed-in bug (e.g., feature) that probably can't be changed without making some legacy code not work. But at least, T and F could be removed soon as synonms for TRUE and FALSE. We have seen that _ was removed as an assignment operator, and the world did not crumble. The use of T and F is no less error-prone, and possibly more. The only immediate solution to this accretion of overly clever behavior would be for someone to write new functions (say, Read.csv) that didn't do all those conversions behind the scenes. I'm not about to do that. Are you? Best of luck! -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] how can I use R functions in Fortran 90
Anny Huang annylhu...@gmail.com wrote: Is there a way that I can import R functions into Fortran? Especially, I want to generate random numbers from some not-so-common distributions (e.g. inverted chi square) but did not find any routines written in Fortran that deal with distributions other than uniform and normal. If you are interested in pure Fortran code for the problem, you could look at routine G01FCF here: http://gams.nist.gov/search.cgi?Pattern=chi+squareBoolean=ANDMatch=FullLimit=100Show=Yes GAMS (the Guide to Available Mathematical Software) has a lot of good code. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Entire Organization Switching from SAS to R - Any experience?
Kel Lam lamk...@gmail.com wrote: My institute has been heavily dependent on SAS for the past while, and SAS is starting to charge us a very deep amount for license renewal. Since we are a non-profit organization that is definitely not sustainable. The team is brainstorming possibility of switching to R, at least gradually. I am talking about the entire institute with considerable number of analysts using SAS their entire career. Theres a handful of us using R regularly. What kind of problems and challenges have you faced? Any insight is much appreciated. Thank you very much! Kelvin Background: I used SAS intensively for about 15 yr, I used Systat for about 5 yr, and now I use R almost exclusively. The group I work with has changed from mostly SAS to mostly R over the years. My advice is, think about training. Because SAS and R have such different models of how statistical programming is structured, it's not trivial to switch from one to the other. A lot will depend on what sort of work you are doing. The main problem we've experienced is that R does not easily handle very large datasets on standard PC hardware. We still do some processing with SAS in those cases, though we've been able to reduce the number of SAS licenses we need. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] ' R ' - General Question (newbie)
Jay Mistry jayc...@gmail.com wrote: First-off, I apologize if this is the wrong list to post to, but I would like to install and try out 'R', as an alternative to 'SAS' . As a newbie, could you pl let me know about the following (in terms of online resources and print books) 1) Basics of 'R' 2) Where to download How to install it on Windows (XP), and any needed add-on modules (for Data Analysis and Biostatistics procedures) + others similar to ODS of SAS. 2) Any print/ online documentation for the beginning user of R. Gabor has given a useful suggestion: looking online. You will find that R syntax (and mindset) are quite different from SAS, so using an introductory text will save you time. I think Peter Dalgaard's Introductory Statistics with R is quite a good one, especially if you prefer something in the print (rather than electronic) medium. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] replacing zeros by NAs
Often, data are computed in real (not integer) numbers, and in such cases, comparison to zero is not as good as using a tolerance level. Modifying slightly the suggestions of others, I would use something like this: my.tol - 1e-50 x - c(1.4, 2.97, 1.0e-100, pi, 0.2, 5.1, 6.8, 0.0) print(x) is.na(x) - abs(x) my.tol print(x) -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] limits
Uwe Ligges lig...@statistik.tu-dortmund.de wrote: So you want some software that can do symbolic calculations? In that case use other software. R is designed for numerical analyses. In particular, if you are looking for good free software, you might try Maxima. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] 3D or 4D plot
kapo coulibaly kmcou...@gmail.com wrote: I have data on a regular grid in the format: x y z data. I would like to be able to plot them in 3d kind of like a volume or a mesh with colors. Is that possible in R and how? I've posted code for a 4-D plot here: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=90 It seems to be quite close to what you're looking for. Mike -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Programming Question (setting ylim generally)
stephen sefick ssef...@gmail.com wrote: low - min(a*0.98)-(min(a)*0.04) high - max(a*1.02)+(max(a)*0.04) plot(a, ylim=c(low, high)) Unless I am misreading your example, this can be done a little more compactly as: plot(a, ylim = range(a * 0.94, a * 1.06)) -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Generating GUI for r-scripts
Daren Tan dare...@hotmail.com wrote: I have developed some scripts that basically ask for input tab-limited format files, do some processing, and output several pictures or csv. Now I need to have some gui to wrap on top of the scripts, [...] Please advice me if there is any tools or project suitable for my tasks. you might take a look at package tcltk, which provides GUI tools by binding to Tcl/Tk. It could meet your requirements. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
[R] Plotmath with values?
I hope to use the plotmath facility to print titles that mix math and values of R variables. The help for plotmath has an example, which after repeated reading, I find baffling. Likewise, I have read the help file for substitute (wqhich seems to be needed) without ever understanding what it does, other than being used in some magic incantations. I would like to do something like this: dev.new() aa - round(pi,2) plot(1:3, 1:3, main = ~ a == aa) and have the main title read a = 3.14 but of course it reads a = aa. From a user's point of view -- one who has never written a parser nor taken a course in compilers -- what is needed is the nonexistent function value usable in plotmath expressions to produce the value of its argument, as plot(1:3, 1:3, main = ~ a == value(aa)) How can this be done? THANKS! -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Plotmath with values?
Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 31 Dec 2008, Mike Prager wrote: I hope to use the plotmath facility to print titles that mix math and values of R variables. [...] plot(1:3, 1:3, main = bquote(a == .(aa))) You have to follow a couple of 'See Also' links from the plothmath page to get to ?bquote HTH, Chuck, THANKS! It helps very much. --Mike __ R-help@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.
Re: [R] names help?
rkevinbur...@charter.net wrote: I am unclear what names(x) - does? On the outset it seems relatively clear. But what if there are already names? What if there are already names on the object and they are in a different order than specified in the names on the right hand side? I tried it and it just replaces what was there as seems the simplest approach. But doesn't that seem a little dangerous? If I swap names for a variable and then later reference the variable by name I would get unexpected results. Right? Kevin Right: when you change a name, the old name no longer works. You can also do things like this, to change specific names: -Begin R session- a = 1:5 names(a) - letters[1:5] a a b c d e 1 2 3 4 5 names(a)[3] - Kevin a a b Kevin d e 1 2 3 4 5 names(a)[which(names(a)==b)] - Brad a a Brad Kevin d e 1 2 3 4 5 -End R session- Does that help? -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Make installed packages available to new R version
Roy Robertson jroyrobert...@comcast.net wrote: After installing a new version of R, how do I make the packages that I have already installed and use on the old version available to the new version? Here is my solution. It has worked over many releases of R, though it will probably require one initial re-installation of packages. Set environment variable R_LIBS to some permanent directory before installing a version of R. (That is, NOT a directory under the tree of your current R version.) When you subsequently install packages, they will go into that location and won't need re-installation with each new version of R. It's still necessary to run update.packages() periodically -- such as after installing a new R version -- to keep the installed packages current. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] optimization problem
Hans W. Borchers [EMAIL PROTECTED] wrote: Why not use one of the global optimizers in R, for instance 'DEoptim', and then apply optim() to find the last six decimals? I am relatively sure that the Differential Evolution operator has a better chance to come near a global optimum than a loop over optim(), though 'DEoptim' may be a bit slow (only for quite large numbers of parameters). Thanks for the reference. I will see if 'DEoptim' might be useful in future problems. HWB asked, why not use 'DEoptim' rather than a loop? Perhaps that's a rhetorical question, but I'll answer it anyway, in the context of the specific problem I am solving. (1) I did not know that 'DEoptim' existed. (2) After starting a problem with 'nls', I changed its structure slightly, which meant a change to 'optim'. Because the two functions have totally different syntaxes, it was necessary to rewrite the entire script and its supporting functions. Adding a loop was much simpler than looking for yet *another* optimizer in R. (3) In the current problem, perhaps 97 of 100 runs of 'optim' come to the same solution (the best one found). That suggests that this is not a terribly difficult problem and that there is little to be gained by employing a different approach. SOMEONE once posted about an R function that masked the syntax differences among (at least some) R optimizers. That surely would lower the barrier to switching among them. I've lost that post, and my search has not turned it up. If that poster is reading this, would you please respond with the information? ALSO, is anyone aware of any document comparing the various optimizers available in R (even in core R)? What are the different intended applications, and when would each be preferred? There is some helpful material in MASS 4, but I am hoping for something more recent and detailed. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] optimization problem (optim vs. nlminb)
In case anyone is still reading this thread, I want to add this: In a current problem (a data-shy five-parameter nonlinear optimization), I found nlminb markedly more reliable than optim with method L-BFGS-B. In reviewing the fit I made, I found that optim only came close to its own minimum in about 13 of 120 trials (same data, different starting values). I previously said 97, but I was clearly looking at the wrong data! In contrast, nlminb came to that best answer in about 92 trials out of 120. The original poster might consider nlminb instead of optim. Because nonlinear optimization is sensitive to starting values, I would still advise solving the problem a number of times to see if a clear minimum solution emerges. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] optimization problem
tedzzx [EMAIL PROTECTED] wrote: If I want to find out the globle minia, how shoul I change my code? I sometimes use optim() within a loop, with random starting values for each iteration of the loop. You can save the objective function value each time and pick the best solution. Last time I did that, I ran it 100 times. That procedure does not guarantee finding the global minimum. However, it does make it *more likely* to find the global minmum *within the range of your starting values*. Often, I make a boxplot of the various results. If they don't show a strong mode, there is a data or model problem that needs to be addressed. For example, the solution may be poorly defined by the data, or the model may be specified with confounded parameters. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Replace NaN with zero
Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: I need help with replacing NaN with zero (the value '0') in my dataset. The reason is that I can't get it to graph because of the NaN in the dataset. I have tried: data[is.nan(data)] - 0 that others have suggested in the help archives but this does nothing so I am not sure what I am doing wrong. The function is.nan() does not operate like is.na(). One could consider that a design deficiency in R. You can overcome it with apply(), is in this short script: tmp = data.frame(a = 1:3, b = 4:6) tmp$a[1] = 0/0 print(tmp) a b 1 NaN 4 2 2 5 3 3 6 mask - apply(tmp, 2, is.nan) tmp2 - tmp tmp2[mask] -1000 print(tmp2) a b 1 1000 4 22 5 33 6 Here I used 1000 instead of 0 to make it more easily seen. For plotting, I would not use 0 as you propose, as that will plot a point at zero. It is usually better to use NA, as in is.na(tmp2[mask]) - TRUE HTH -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Replace NaN with zero
Mike Prager [EMAIL PROTECTED] wrote: The function is.nan() does not operate like is.na(). One could consider that a design deficiency in R. I meant to write, design inconsistency. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
[R] Update packages error message
In updating packages (R 2.8.0 on Windows XP SP3), I received an error message (complete with non-ASCII characters as pasted below). This does not seem to have caused a problem. Any idea what is going on and whether it is likely to have consequences? MHP --- update.packages(ask='graphics') trying URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8/XML_1.98-1.zip' Content type 'application/zip' length 1790135 bytes (1.7 Mb) opened URL downloaded 1.7 Mb package 'XML' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\mike.prager\Local Settings\Temp\RtmpcM9EGr\downloaded_packages updating HTML package descriptions Error in .install.winbinary(pkgs = pkgs, lib = lib, contriburl = contriburl, : unable to create temporary directory '4xlhúy $ ð¹? R-utils' -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] IWLS vs direct ML estimation
sandsky [EMAIL PROTECTED] wrote: I am thinking about IWLS vs ML estimation. When I use glm() for a 2-parameter distribution (e.g., Weibull), I can otain the MLE of scale parameter given shape parameter through IWLS. Because this scale parameter usually converges to the MLE. In this point, I am wondering: i) can you say that the direct MLE, which is obtained by maximizing a likelihood function, is equalvant to the indirect MLE, which is obtained by IWLS? ii) if not or the glm approach is better, why we use the glm approach to find the indirect MLE? You may want to read the following paper: Bradley, E. L. 1973. The equivalence of maximum likelihood and weighted least squares estimates in the exponential family. J. Am. Stat. Assn. 68: 199. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] IWLS vs direct ML estimation
sandsky [EMAIL PROTECTED] wrote: I think that IWLS provides the computational flexibility. Because when there exists no analytical solution, IWLS makes it possible to solve via the numerical solution. Do you have any idea for this? My impression is the same as yours. M.H.P. __ R-help@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.
Re: [R] Maximum number of pasted 'code' lines?
Michael Just [EMAIL PROTECTED] wrote: I write most of my R code in excel and then paste it into R. I am wondering if there is a limit to how much I can paste? I want to paste about 19,000 lines of code should this work? I am doing this because when I did it chunks it took about an hour and half. I thought if I could insert it all and leave it for that long that would be better time management. I am still waiting for 19,000 paste to process. Any thoughts or suggestions? Write your code in a text editor and include it with the source function. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Return a list
Stefan Fritsch [EMAIL PROTECTED] wrote: I have several output variables which I give back with the list command. test - function {return(list(a,b,c,d,e,f,g,...))} After the usage of the function I want to assign the variables to the output variables. result - test() a - result$a b - result$b c - result$c d - result$d ... is there a more elegant way to assign these variables, without writing them all down? thank you very much for your help! I don't have a good answer for your question, but I do encourage you to choose a method that will be readily intelligible to you when you revisit your code X years later. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] migrating data from s-plus to R
Patrizio Frederic [EMAIL PROTECTED] wrote: Dear all, is there any way to transform a .Data directory created in S-plus 6.1 for windows in a .RData file? You might try the functions dump or dput, which create text representations readable by either S or R. At least, they do so for many common data objects -- I can't say whether they will do so for specialized ones or not. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Writing greek letters and subscripts in graph
Delphine COURVOISIER [EMAIL PROTECTED] wrote: I would like to write Greek letters followed by subscripts in a graph (on the X-axis and in a legend). I would appreciate any help. As others have said, try demo(plotmath) and also ? plotmath Here's a brief example: plot(1:10, 1:10) title(Concentration of ~alpha[3]) text(2,3, ~ beta[z]) Note the use of ~ to denote an expression, so that the material following the tilde is interpreted as such. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] graphsheet
Applejus [EMAIL PROTECTED] wrote: I am trying to convert the following command from SPLUS to R: graphsheet(pages = TRUE) Does anyone have an idea what is the equivalent in R? I would use windows(record = TRUE) which won't give a tabbed graphics device, but will allow you to page and down through the list of plots. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Larger Fonts for x/y-axis
Andreas Tille [EMAIL PROTECTED] wrote: what is the trick to get larger fonts for Graphs to make a good slide for presentations? Generally I use something like cex = 2 in the plot function, as well as lwd = 3 -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] ignoring zeros or converting to NA
rcoder [EMAIL PROTECTED] wrote: I have a matrix that has a combination of zeros and NAs. When I perform certain calculations on the matrix, the zeros generate Inf values. Is there a way to either convert the zeros in the matrix to NAs, or only perform the calculations if not zero (i.e. like using something similar to an !all(is.na() construct)? Is this what you are looking for? # make some data a = matrix(c(rep(0,6), rep(2,6)), nrow = 4) a [,1] [,2] [,3] [1,]002 [2,]002 [3,]022 [4,]022 # change zero to NA is.na(a[a==0] ) - TRUE a [,1] [,2] [,3] [1,] NA NA2 [2,] NA NA2 [3,] NA22 [4,] NA22 -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] try question
Edna Bell [EMAIL PROTECTED] wrote: Hi still yet again! I have the following code: try(log(rnorm(25)),silent=TRUE) [1] -0.26396185 NaN NaN -0.13078069 -2.44997193 -2.15603971 NaN 0.94917495 0.07244544 NaN [11] -1.06341127 -0.42293099 -0.53769569 0.95134763 0.93403340 NaN -0.10502078 NaN 0.30283262 NaN [21] -0.11696872 -3.84122332 NaN NaN -0.12808690 Warning message: In log(rnorm(25)) : NaNs produced I thought that putting the silent = TRUE would suppress the warnings, please. What should I do instead, please? It's not a great idea to take logs of negative numbers. Better than supressing the resulting messages, you might try something like this: a - rnorm(25) b - log(ifelse(a 0, NA, a)) which gives this: a [1] -0.04816269 -0.50745059 0.15229031 0.54735811 [5] -0.29896853 1.81854119 0.19462259 -0.48984075 [9] 0.63489288 1.47432484 1.15295160 0.75842227 [13] 0.07918115 1.04596643 1.31722543 -0.03614219 [17] 0.44072181 0.25358843 -0.49626405 -2.10954780 [21] -0.85815654 1.38983430 0.66592947 0.64700068 [25] -1.17829527 b [1] NA NA -1.8819 -0.60265201 [5] NA 0.59803463 -1.63669302 NA [9] -0.45429898 0.38820015 0.14232526 -0.27651496 [13] -2.53601706 0.04494127 0.27552758 NA [17] -0.81934141 -1.37204269 NA NA [21] NA 0.32918453 -0.40657152 -0.43540794 [25] NA See the help page for ifelse() for more information. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Change font-face in title
Ok, thanks! Gabor Grothendieck [EMAIL PROTECTED] wrote: See ?title where its mentioned that calls are ok and a formula is a call. Actually the first ~ is not needed since its already a formula. On Tue, Jul 22, 2008 at 1:12 PM, Mike Prager [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] wrote: plot(1, type=l, xlab=Wellenlänge [nm], col=darkslategray, main = ~ Spektrum ~ italic(Deschampsia caespitosa)) That clearly works, but why? Does the tilde cause the rest of the text to be parsed as an expression? This looks extremely useful, and I am grasping for the underlying principle. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Change font-face in title
Gabor Grothendieck [EMAIL PROTECTED] wrote: plot(1, type=l, xlab=Wellenlänge [nm], col=darkslategray, main = ~ Spektrum ~ italic(Deschampsia caespitosa)) That clearly works, but why? Does the tilde cause the rest of the text to be parsed as an expression? This looks extremely useful, and I am grasping for the underlying principle. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] drawing segments through points with pch=1
David Epstein [EMAIL PROTECTED] wrote: Please excuse me for asking such basic questions: Here is my code y=c(1.21,0.51,0.14,1.62,-0.8,0.72,-1.71,0.84,0.02,-0.12) ybar=mean(y) ll=length(y); ybarv=rep(ybar,ll) x=1:ll plot(x,ybarv,pch=1) segments(x[1],ybar,x[ll],ybar) What I get is a collection of small circles, with a segment on top of the circles, which is almost what I want. But I don't want the segment to be visible inside any small circle. Is there an easy way to arrange for the segment to lie behind the pch=1 markers, as in hidden line removal, so that the circles remain with nothing inside them? I tried putting the segments command first, but then no segment appeared at all. Try using pch = 21 and the bg parameter to set the fill color. That lets you set the background color of the circle so that it will conceal the line segment. In general in R graphics, objects are drawn in the order specified. However, the default background of plotting symbols is transparent, so in your case, the order doesn't matter. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Font quality in base graphics
willemf wrote on 07/15/2008 08:42 AM: I am attempting to get publication quality graphs using R on Ubuntu. I encounter lots of problems in using cex to control font size: for instance cex=1.5 results in very blocky characters. I then tried to use res=1200 while creating a PNG file, hoping that this would solve the problem, but it did not. When doing the above, a second problem appeared: the font size relative to the graphics decreased drastically. e.g. png(t1.png, res=1200, width=1200, height=1200). Is anyone prepared to give me a pointer of where to read about precise control over font type and font size in base graphics? I have two books on R graphics but this aspect is never treated in detail in any of them. Kind regards, willemf. Any reason not to use PDF or EPS? They are vector graphics formats and will provide better text. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Lattice + Word: Changing .wmf files to .pdf files
Jim Price [EMAIL PROTECTED] wrote: [...] Currently we are using windows metafile format for in-text tables for reports created in Word. However, we've discovered some artifactual lines being created in our final output once the Word document is changed to PDF. The process is as follows: [...] If any one can shed enlightenment (or suggest an alternative approach that preserves decent fidelity - we've struggled with postscript files in the past, but this may be our opportunity to try them out again), it would be much appreciated. The best approach depends on how much you care about the Word files looking their best before conversion, vs. caring most about the PDF. If you care most about the PDF, you can save your graphics as EPS files from R (either by using the postscript device or the savePlot function with type = eps). I tried one EPS file, and found that Word 2007 imported EPS better than some older versions. When I converted to PDF, the graphic was sharp and clear. The downside of this approach is that before the conversion Word displays the EPS graphic as a rough bitmapped preview -- quite workable, but not suitable for final version. If you want both Word and PDF versions to look good, there is no perfect solution. You could try generating the graphics as PNG, which will look good (but not great) in both places. That approach will likely increase file sizes considerably. Hope that helps. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] efficiency profiling?
esmail bonakdarian [EMAIL PROTECTED] wrote: Yes, I have been reading the list, the amount of messages per day is simply amazing, I can hardly keep up. Do most of you read this on the web or get it as digest? I am getting them as individual e-mails (thank god for filters) ... :-) I used filters for a while. Now, I read the R list through the gmane Usenet interface. It appears to me to be a newsgroup, rather than a huge collection of emails. I find that much easier. See http://gmane.org/ -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Bug? in summary( ) function base package
Richard Saba [EMAIL PROTECTED] wrote: There seems to be an error in the summary() function when applied to ts class objects. The results of a call to summary( ), on the R ts data set USAccDeaths , reports the wrong value for Max. The value reported by the summary function is 11320. The max( ) function returns the correct value 11317, the July 1993 value. Coercing the data to a data.frame and calling summary returns the correct max value. A search of R -help found a post in 2007 that mentioned a problem but attributed it to rounding errors. But this is too large a difference to account for a simple rounding error. Has anyone else encountered the problem? Is there a workaround? A documented feature of summary() is that it rounds values. In doing so, it may print meaningless digits and thus give the appearance of more precision than is really represented. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Use of recordPlot
Beck, Kenneth (STP) [EMAIL PROTECTED] wrote: To be able to page through plots, open the graphics device with recording turned on before plotting. Then you can use PageUp and PageDown keys to see the plots in sequence. The plots are stored into .SavedPlots. (AFAIK they cannot be accessed with replayPlot. I don't use that, but I think it is used when a plot has been saved into a variable with the recordPlot function.) To enable this sort of session-specific recording, I use the following code in an script before plotting: graphics.off() windows(record = TRUE) .SavedPlots - NULL * The first line closes any open graphics devices. * The second line opens a new device (here a windows device, but you could use X11) with plot recording turned on. * The third line erases any plots already stored in the plot-recording history. If you don't do this, they will persist across script runs and even sessions. You may need to change the code to suit your own needs. Does that help? Mike [...] But the end of your response hits on the key issue: when I create several graphs, I would like to be able to use PgUp/PgDn or some other keystroke to easily scroll through them all in sequence. One of my scripts now creates 30+ graphs, and to view them I have to mouse to the list of graphics devices and pick off the list. Your last comment indicates you can set it up to quick page through lists of graphs. I just tried adding options(graphics.record=TRUE); to my code, and I now find the .SavedPlots variable in the work space, but I was hoping to use replayPlot(.SavedPlots) or something like that to be able to scroll through the plots, but it does not seem to work. [...] Is there a simple command or series of commands to add to the script to enable scrolling through all plots generated by that script? Or maybe something at the beginning with something else at the end?? -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Writing list object to a file
Arun Kumar Saha [EMAIL PROTECTED] wrote: Hi all, I am wondering how to write a 'list' object to a file. I already gone through some threads like http://mail.python.org/pipermail/python-list/2001-April/080639.html, however could not trace out any reliable solution. I tried following : write.table(calc, file=c:/data.csv) Error in data.frame(200501 = c(-0.000387071806652095, -0.000387221689252648, : arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19, 23, 20, 11 Anybody can help? Remember that a list is not a rectangular table. It may have components of various types and shapes. Therefore, it's unlikely you'll be able to write a file that can be read easily by another program. That said, we do this occasionally for users who want to use spreadsheets (yuck!) to analyze part of a list. We use the following function, which simply prints the list to an ASCII file with a long line length: ## # File: Robj2txt.r # Language: R # Programmer:Michael H. Prager # Date: July 7, 2004 # Synopsis: # Function to write a complex R object to an ASCII file. # Main use is to write objects created from .rdat files; # however, could be used to save other objects as well. # This can be used to create files for those who want to use # a spreadsheet or other program on the data. ### Robj2txt - function(x, file = paste(deparse(substitute(x)), .txt, sep = )) { # # ARGUMENTS: # x: R data object to save as ascii # filename: Name of file to save. Default is name of x with .txt extension # tmp.wid = getOption(width) # save current width options(width = 1)# increase output width sink(file)# redirect output to file print(x) # print the object sink()# cancel redirection options(width = tmp.wid) # restore linewidth return(invisible(NULL)) # return (nothing) from function } ## -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] graphics history
Duncan Murdoch [EMAIL PROTECTED] wrote: One thing I'd like to do, but didn't have time to implement before 2.7.0, is to have history set to some finite size, e.g. a default might be the last 3 or 10 plots. The problem with record=TRUE is that it keeps a record of all the plots, so memory use just increases and increases. Why not just startup another device with record=FALSE? I'd like to have recording always on, but I don't need an infinite history. But this isn't urgent enough to have prodded me into writing it before now. A finite size would be nice. I've been using this code in scripts: graphics.off() windows(record = TRUE) .SavedPlots - NULL Not exactly the same thing, but it limits memory use. Are there side effects that could bite me? -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] plot data with a colour scale
merca duria [EMAIL PROTECTED] wrote: I have a two dimensional data (X,Y) that I want to represent with different colours, I want to make a plot with a graduate color scale at right, or below Take a look at the levelplot function in the lattice package. require(lattice) ?levelplot -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Adding average into a matplot?
-Halcyon- [EMAIL PROTECTED] wrote: I have a matrix which is filled with simulation results for several years. Example of an output (7 years, 4 simulations): [...] My matplot gives me 4 lines, but I would like to add a line with the averages of each year for all simulations. Can anyone help me with this? Take a look at help pages of the following functions: mean, apply, abline. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] How to add background color of a 2D chart by quadrant
tom soyer [EMAIL PROTECTED] wrote: I have a 2D chart that is divided into four quadrants, I, II, III, IV: plot(1:10,ylim=c(0,10),xlim=c(0,10),type=n) abline(v=5,h=5) text(x=c(7.5,7.5,2.5,2.5),y=c(2.5,7.5,7.5,2.5),labels=c(I,II,III,IV)) I would like to fill each quadrant with a background color unique to the quadrant. Does anyone know how to do this in R? In response to a similar question no more than two weeks ago, I posted detailed code as an example. I expect it would be easy to modify my example to fit your question. If you search the group archives, you should be able to find it. The thread title was background color in scatterplots. MHP -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] background color in scatterplots
Georg Ehret [EMAIL PROTECTED] wrote: Dear R community,I have a scatterplot with multiple vertical ablines. I wish to color each interval between two ablines in a different color... Could you please indicate me how to do this efficiently? Thank you! Georg. Dear Georg, Try this example: # Demonstrate scatterplot w/ different color bands # M.H.P. - March 2008 graphics.off() # Generate dummy data make a blank plot: a - runif(100) b - 2 * runif(100) plot(a, b, type = n, main = Demonstration) # Set the values of the x-axis references: vrefs - c(0.2, 0.4, 0.6) # Get coordinates of plot pdims - par()$usr # Concatenate them to the vector of x_axis references: vrefs2 - c(pdims[1], vrefs, pdims[2]) # Generate some weak colors: cols - rainbow(n = length(vrefs2), s = 0.15) # Add the colors to the plot: for (i in 2:length(vrefs2)){ polygon(c(vrefs2[(i-1):i], vrefs2[i:(i-1)]), c(rep(pdims[3],2), rep(pdims[4],2)), col = cols[i], border = NA) } # Draw the reference lines, points, and box: abline(v = vrefs) points(a, b, lwd = 1.5) box() -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Extracting single output data into a vector or matrix
Ayman, It is difficult to say without seeing some code, but your output seems to be not a list in the R sense but a collection of vectors, each of length 1. The best way to put the values into a vector probably is to assign them to the elements of the vector during your computations. Mike Prager Ayman Oweida [EMAIL PROTECTED] wrote: I've been struggling to do the following: After a lengthy computation, I receive an output along the lines of the list below. This list has 41 values and is not the end of my computations. I have another computation to do on the list below, but in this final computation the list is supposed to be a vector. I've tried to assign the list below to a data frame and then extract it, but not luck! Cleary, this is because each of the outputs in the list represents an individual data point that is not regarded as part of a matrix. Any help? I desperately need to be able to extract all the output data into a Vector so I can perform the final step of my computation. Thanks in advance. [1] 1.573233e-10 [1] 2.939187e-10 [1] 5.491124e-10 [1] 1.025877e-09 [1] 1.916591e-09 [1] 3.580663e-09 [1] 6.689559e-09 [1] 1.249774e-08 [1] 2.334885e-08 [1] 4.36214e-08 [1] 8.149551e-08 [1] 1.522537e-07 [1] 2.844473e-07 [1] 5.314175e-07 [1] 9.928186e-07 [1] 1.854829e-06 [1] 3.465277e-06 [1] 6.47399e-06 [1] 1.209501e-05 [1] 2.259645e-05 [1] 4.221572e-05 [1] 7.886935e-05 [1] 0.0001473473 [1] 0.0002752811 [1] 0.0005142927 [1] 0.0009608253 [1] 0.001795058 [1] 0.00335361 [1] 0.006265368 [1] 0.01171493 [1] 0.02188637 [1] 0.04088913 [1] 0.07639071 [1] 0.1427168 [1] 0.2666308 [1] 0.4981322 [1] 0.9306848 [1] 1.738748 [1] 3.248409 [1] 6.068827 [1] 11.33806 - [[alternative HTML version deleted]] __ R-help@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. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Reading a file created with Fortran
Ben Bolker [EMAIL PROTECTED] wrote: Dennis Fisher fisher at plessthan.com writes: I am trying to read a file written by Fortran. Several lines of the file are pasted below: Perhaps read.fwf is what you want? (fwf stands for fixed width format). You would have to work out the field widths, but it would seem to be pretty straightforward). A couple of points. First, since you know the format statement, perhaps you control the Fortran program. Then, it might be nicer to introduce whitespace between the data items, which would serve two purposes: making read.table() work on the data set and making it easier for humans to check the data file more easily. Second, you could look at read.fortran() -- a function that takes a lightly modified Fortran format specification as an argument. That seems even better for your purposes than read.fwf. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] numeric format
Rolf Turner [EMAIL PROTECTED] wrote: I have often wanted to suppress these row numbers and for that purpose wrote the following version of print.data.frame() [...] The ``srn'' argument means ``suppress row numbers''; [...] I once suggested to an R Core person that my version of print.data.frame() be adopted as the system version, but was politely declined. Rolf-- Clearly, and appropriately, R development is not a democratic process. Still, if a vote were held, I would support your version. I have also needed to suppress row names from time to time. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Rating R Helpers
John Sorkin [EMAIL PROTECTED] wrote: I believe we need to know the following about packages: (1) Does the package do what it purports to do, i.e. are the results valid? (2) Have the results generated by the package been validate against some other statistical package, or hand-worked example? (3) Are the methods used in the soundly based? (4) Does the package documentation refer to referred papers or textbooks? (5) In addition to the principle result, does the package return ancillary values that allow for proper interpretation of the main result, (e.g. lm gives estimates of the betas and their SEs, but also generates residuals)?. (6) Is the package easy to use, i.e. do the parameters used when invoking the package chosen so as to allow the package to be flexible? (7) Are the error messages produced by the package helpful? (8) Does the package conform to standards of R coding and good programming principles in general? (9) Does the package interact will with the larger R environment, e.g. does it have a plot method etc.? (10) Is the package well documented internally, i.e. is the code easy to follow, are the comments in the code adequate? (11) Is the package well documented externally, i.e. through man pages and perhaps other documentation (e.g. MASS and its associated textbook)? In addition to package evaluation and reviews, we also need some plan for the future of R. Who will maintain, modify, and extend packages after the principle author, or authors, retire? Software is never done. Errors need to be corrected, programs need to be modified to accommodate changes in software and hardware. I have reasonable certainty that commercial software (e.g. SAS) will be available in 10-years (and that PROC MIXED will still be a part of SAS). I am far less sanguine about any number of R packages. John Interesting questions. Re, the future : LaTeX provides an example. The more complex packages tend to stop developing when the original programmer loses interest. Sometimes another person picks one up, but not frequently. I think, for example, of the many slide-preparation packages, each more complex than the next, that have come and gone during my relatively short (15 yr) professional use of LaTeX. At its root, this is a rather deep question: how open-source, largely volunteer-developed software can survive over the long term, while continuing to improve and maintain high standards. We are rather early in the history of free software development to know the answer. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] [OT] putting URLs in Latex
Edna Bell [EMAIL PROTECTED] wrote: Hi R Gurus! This is definitely off topic, but I thought I'd try: what is the way to put in url's into a Latex file, please? In future, you might want to post such questions in group comp.text.tex Mike -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] R graph window
Duncan Murdoch [EMAIL PROTECTED] wrote: I am using R 2.6.0 on Windows XP. I am wondering if R can show multiple graph at the same graph window with different tabs at the bottom of the window, like in S-plus. Does anybody have experience on this? No, it can't. If you turn history recording on (see the History menu entry when the graphics window has the focus), then R will save the plots and PgUp/PgDn will scroll through them. To enable that, I usually begin an R script: graphics.off() .SavedPlots - NULL # Deletes any existing plot history windows(record = TRUE, ...) You might also be interested in the savePlot function, well described in the R help files. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] writing summary() to a text file
Federico Calboli [EMAIL PROTECTED] wrote: I would like to output the results of a function into a text file, legible as a such. The function produces a summary quite like: Take a look at the sink() function. Does that do what you need? -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Packages - a great resource, but hard to find the right one
hadley wickham [EMAIL PROTECTED] wrote: Which moves somewhat back towards my original suggestion of review articles. To me, an article which compared and contrasted four or five packages on a given topic would be much more useful than an article which reviewed only a single package. I think basing reviews around a specific topic/methodology would be more useful than basing them around a single package. I agree: Such articles would be welcome resources if published either in JSS or in R-News. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Packages - a great resource, but hard to find the right one.
John Sorkin [EMAIL PROTECTED] wrote: The multitude of packages is one of the great strengths of R. Unfortunately there is no (or at least I am not aware of) any single source that lists all available packages and gives a synopsis of what each package does. One can install and load packages one-by-one and look at the help pages to see what each package does, but this is at best an inefficient and a worst a very frustrating task. Might there be a way to put together a searchable database that will allow a user to easily search for a given function or technique in all contributed packages? Besides the excellent answers already given, don't overlook Google. Searching on r statistics box-cox transform turns up a reference to MASS as the third entry. When programming in any language, I now find it quicker to search for syntax (and other) help by Googling than to pull the reference manual off the shelf or start up an online help file. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.
Re: [R] Help for Beginner!!
Leandre Bassole [EMAIL PROTECTED] wrote: I am a new user of R. I am very familar to Stata, but few days ago I have decided to switch to R. But R langage is very difficult.I really want to know the best way to learn this famous and interesting software. I agree with the suggestions made so far. Also, consider buying or borrowing a copy of Introductory Statistics with R by Peter Dalgaard. It is well written and brief. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@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.