Re: [R] Making TIFF images with rtiff
http://www.ebi.ac.uk/~osklyar/EBImage or http://bioconductor.org/packages/2.0/bioc/html/EBImage.html will read/write more than 90 formats including TIFF. Trivial to install and run on Windows. Regards, Oleg On 12/01/07, Inman, Brant A. M.D. [EMAIL PROTECTED] wrote: Many medical journals and publishers require that images, whether photographs or line art, be submitted as high resolution .TIFF images. One option for R users is to produce an image in one format and to convert it to a .TIFF file using a second software program. My experience has been that this option often results in images of poorer quality, often with blurry contours, and a loss of resolution. A second and better option would be to make .TIFF files directly from the graphic output of R. I recently noticed that there is a library called rtiff that may be able to do this. However, I have not been able to get it to work, principally because I do not know how to install the required supporting software, libtiff and tiffio.h, correctly on my computer. I am running R 2.4.0 on a Windows XP machine. So far I have done the following: 1) Loaded the rtiff library 2) Downloaded and installed the TIFF library 3.8.2 (complete package and sources) from the following website: http://gnuwin32.sourceforge.net/packages/tiff.htm I would like to ask the R experts for help with the following things: 1) Where do I get the tiffio.h file? 2) Where do I install or relocate the tiffio.h and TIFF library to so that rtiff will work? Thanks for your help. Brant Inman Mayo Clinic __ R-help@stat.math.ethz.ch 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. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] kate editor for R
On 1/20/07, Marc Schwartz [EMAIL PROTECTED] wrote: xft anti-aliasing is incorporated into the version 23 unicode trunk. So it looks great on a hi-res LCD panel. Without xft, even using Bitstream fonts, it was still pretty rough on the eyes. Humm, call me silly, but most of the time I do not like anti-aliased fonts: I tend to agree with http://modeemi.cs.tut.fi/~tuomov/ion/faq/entries/Blurred_fonts.html, where he says characters look like having been dragged through mud :-). It also fully supports GTK widgets, which is great if you are using GNOME, which I do. But my .emacs gets rid of the toolbar and scroll bars on start-up (I find toolbars confusing things that take up precious screen space), and often work without the menubar (when I am doing familiar work). I use ion3 (http://modeemi.cs.tut.fi/~tuomov/ion/), which, together with wmii (and followed, at some distance, by fmwv), I find the most usable window managers, and thus the look of widgets is not that relevant to me. So, for most practical purposes (except for resizing with the mouse) I use emacs as if started with the -w command. (I know, I know, this looks like going backwards ... must be a mid-life involution crisis :-). xft was added as a patch to version 22, but it was not very stable. Note that version 23 is in alpha status, so use at your own risk if you decide to pursue this. 21 is still the current stable release version, but 23 has been rock solid for me. I can provide you with a shell script to build it. Let me know. Let me try with the debian packages, and if I have problems, I'll definitely start bugging you. Thanks a lot for your help! Best, R. Best regards, Marc On Sat, 2007-01-20 at 03:59 +0100, Ramon Diaz-Uriarte wrote: Hi Marc, Thanks a lot for the detailed explanation! I'll give it a try. (But still, why emacs23? what is missing in v. 21 that you get in 23?). Best, R. On 1/19/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Fri, 2007-01-19 at 16:09 +0100, Ramon Diaz-Uriarte wrote: snip I had problems with one of the packages ecb depends upon (semantic ?), and emacs-snapshot. IIRC it was a documented problem related to a bug in semantic (?); maybe it's been fixed now. But what does emacs-snapshot-gtk provide you now (besides the pretinness) that you'd miss with 21-4? snip Ramon, Just a quick heads up on the ECB issue. I am using Emacs 23 from CVS and had to update ECB and the associated packages to use this version of Emacs. I have emacs 23 installed and run from a separate download folder, so that I do not overwrite the installed stable version. I use the CEDET cedet-1.0pre3.tar.gz aggregate package from http://cedet.sourceforge.net/ as well as the ECB cvs snap shot package ecb.tar.gz from http://ecb.sourceforge.net/downloads.html. The CEDET package includes cogre, ede, eieio, semantic and speedbar. Extract these two files and then modify ~/.emacs with the following: ;; Load ECB (setq semantic-load-turn-everything-on t) (load-file /PATH/TO/CEDET/cedet-1.0pre3/common/cedet.el) (add-to-list 'load-path /PATH/TO/ECB/ecb-snap) (require 'ecb) And all seems well. HTH, Marc Schwartz -- Ramon Diaz-Uriarte Statistical Computing Team Structural Biology and Biocomputing Programme Spanish National Cancer Centre (CNIO) http://ligarto.org/rdiaz __ R-help@stat.math.ethz.ch 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] Insert R logo
Dear all R users, I want to insert the R logo in every graphic that I made in my Statistical analysis using R. Can anyone tell me whether is it possible or not and if possible how to do this? your help will be highly appreciated. Thanks and Regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] aov y lme
Dear R user, I am trying to reproduce the results in Montgomery D.C (2001, chap 13, example 13-1). Briefly, there are three suppliers, four batches nested within suppliers and three determinations of purity (response variable) on each batch. It is a two stage nested design, where suppliers are fixed and batches are random. y_ijk=mu+tau_i+beta_j(nested in tau_i)+epsilon_ijk Here are the data, purity-c(1,-2,-2,1, -1,-3, 0,4, 0,-4, 1, 0, 1,0,-1,0, -2,4,0,3, -3,2,-2,2, 2,-2,1,3, 4,0,-1,2, 0,2,2,1) suppli-factor(c(rep(1,12),rep(2,12),rep(3,12))) batch-factor(rep(c(1,2,3,4),9)) material-data.frame(purity,suppli,batch) If I use the function aov, I get material.aov-aov(purity~suppli+suppli:batch,data=material) summary(material.aov) Df Sum Sq Mean Sq F value Pr(F) suppli2 15.056 7.528 2.8526 0.07736 . suppli:batch 9 69.917 7.769 2.9439 0.01667 * Residuals24 63.333 2.639 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 and I can estimate the variance component for the batches as (7.769- 2.639)/3=1.71 which is the way it is done in Montgomery, D. I want to use the function lme because I would like to make a diagnosis of the model, and I think it is more appropriate. Looking at Pinheiro and Bates, I have tried the following, library(nlme) material.lme-lme(purity~suppli,random=~1|suppli/batch,data=material) VarCorr(material.lme) Variance StdDev suppli =pdLogChol(1) (Intercept) 1.563785 1.250514 batch = pdLogChol(1) (Intercept) 1.709877 1.307622 Residual2.638889 1.624466 material.lme Linear mixed-effects model fit by REML Data: material Log-restricted-likelihood: -71.42198 Fixed: purity ~ suppli (Intercept) suppli2 suppli3 -0.417 0.750 1.583 Random effects: Formula: ~1 | suppli (Intercept) StdDev:1.250514 Formula: ~1 | batch %in% suppli (Intercept) Residual StdDev:1.307622 1.624466 Number of Observations: 36 Number of Groups: suppli batch %in% suppli 312 From VarCorr I obtain the variance component 1.71, but I am not sure if this is the way to fit the model for the nested design. Here, I also have a variance component for suppli and this is a fixed factor. Can anyone give me a clue? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Insert R logo
I expect you could do something with the addlogo function in the pixmap package. On 20/01/07, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear all R users, I want to insert the R logo in every graphic that I made in my Statistical analysis using R. Can anyone tell me whether is it possible or not and if possible how to do this? your help will be highly appreciated. Thanks and Regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch 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] Insert R logo
Something like this: library(pixmap) # From the addlogo example x - read.pnm(system.file(pictures/logo.ppm, package=pixmap)[1]) fg - matrix(c(0,1,0,1,0,.05,0,.05), ncol=4, byrow=TRUE) split.screen(fg) screen(1) plot(rnorm(100)) screen(2) addlogo(x,c(0,1),c(0,1)) On 20/01/07, Arun Kumar Saha [EMAIL PROTECTED] wrote: Dear all R users, I want to insert the R logo in every graphic that I made in my Statistical analysis using R. Can anyone tell me whether is it possible or not and if possible how to do this? your help will be highly appreciated. Thanks and Regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch 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] ECB/Sidebar/R (Emacs) was: Re: kate editor for R
On Friday 19 January 2007 15:39, Dirk wrote: As I am doing more C++ work, I glanced at oo-browser, sidebar, ecb (all in Debian/Ubuntu). Would a real Emacs hacker be able to these to R code too? Dirk - That functionality (though relatively minimal, i.e. ECB/sidebar support through imenu) should have existed for 2+ years now, at least it does for me. best, -tony [EMAIL PROTECTED] Muttenz, Switzerland. Commit early,commit often, and commit in a repository from which we can easily roll-back your mistakes (AJR, 4Jan05). [EMAIL PROTECTED] pgpGSgF2ik4Rm.pgp Description: PGP signature __ R-help@stat.math.ethz.ch 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] ECB/Sidebar/R (Emacs) was: Re: kate editor for R
Hi Tony, On 20 January 2007 at 15:20, AJ Rossini wrote: | On Friday 19 January 2007 15:39, Dirk wrote: | As I am doing more C++ work, I glanced at oo-browser, sidebar, ecb (all in | Debian/Ubuntu). Would a real Emacs hacker be able to these to R code too? | That functionality (though relatively minimal, i.e. ECB/sidebar support | through imenu) should have existed for 2+ years now, at least it does for me. Just confirms my suspicion that even after all these years, I barely scratched the surface of ess. That '2+ years' old feature wouldn't happen to be documented somewhere, would it? Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch 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] kate editor for R
On Sat, 2007-01-20 at 11:20 +0100, Ramon Diaz-Uriarte wrote: On 1/20/07, Marc Schwartz [EMAIL PROTECTED] wrote: xft anti-aliasing is incorporated into the version 23 unicode trunk. So it looks great on a hi-res LCD panel. Without xft, even using Bitstream fonts, it was still pretty rough on the eyes. Humm, call me silly, but most of the time I do not like anti-aliased fonts: I tend to agree with http://modeemi.cs.tut.fi/~tuomov/ion/faq/entries/Blurred_fonts.html, where he says characters look like having been dragged through mud :-). It also fully supports GTK widgets, which is great if you are using GNOME, which I do. But my .emacs gets rid of the toolbar and scroll bars on start-up (I find toolbars confusing things that take up precious screen space), and often work without the menubar (when I am doing familiar work). I use ion3 (http://modeemi.cs.tut.fi/~tuomov/ion/), which, together with wmii (and followed, at some distance, by fmwv), I find the most usable window managers, and thus the look of widgets is not that relevant to me. So, for most practical purposes (except for resizing with the mouse) I use emacs as if started with the -w command. (I know, I know, this looks like going backwards ... must be a mid-life involution crisis :-). We'll drag you kicking and screaming into the 21st century... ;-) xft was added as a patch to version 22, but it was not very stable. Note that version 23 is in alpha status, so use at your own risk if you decide to pursue this. 21 is still the current stable release version, but 23 has been rock solid for me. I can provide you with a shell script to build it. Let me know. Let me try with the debian packages, and if I have problems, I'll definitely start bugging you. Thanks a lot for your help! Best, R. FWIW, here are some screen shots so that you can get a feel for what it looks like. This is using two 1600x1200 lcd panels. 1. Basic view of main window, showing ECB and ESS: http://home.comcast.net/~marc_schwartz/emacs23.png 2. Full screen (3200x1600 using nVidia TwinView) capture to show GTK file selection widget: http://home.comcast.net/~marc_schwartz/emacs23-2.png 3. View of main window to show the integration of SVN version control, which I use my all of my R code: http://home.comcast.net/~marc_schwartz/emacs23-3.png No doubt that the use of xft is a personal choice, and some folks do not like it, perhaps notably on CRTs. As I have gotten older and need bi-focals for computer work and reading, I find the use of xft much easier and I am less prone to eye strain, given how many hours I typically spend working each day. HTH, Marc __ R-help@stat.math.ethz.ch 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] Offtopic: emacs 23, was kate editor for R
Re-sending to the list as I just got nailed by the too many recipients issue... On Sat, 2007-01-20 at 11:05 -0600, Marc Schwartz wrote: On Sat, 2007-01-20 at 17:37 +0100, Peter Dalgaard wrote: Ramon Diaz-Uriarte wrote: Hi Marc, Thanks a lot for the detailed explanation! I'll give it a try. (But still, why emacs23? what is missing in v. 21 that you get in 23?). Best, R. Ability to load files with UTF-8 characters in the name? (This is pretty maddening if you find yourself with such a beast.) BTW, any inkling when/whether this is heading for Fedora N? Peter, 21.4 is what is presently in the FC7 development trunk (aka rawhide), so I would not expect to see it as a mainstream offering for some time. Needless to say, 23 is still alpha, so the FC timeline is likely more dependent on the upstream timeline to bring 23 to a stable release. Bill Nottingham at RH recently posted this summary of planned key updates to FC7: http://www.redhat.com/archives/fedora-devel-list/2007-January/msg00091.html and based upon subsequent communications, there has been at least one addition, which is the previously discussed replacement of teTeX with TeXLive: http://fedoraproject.org/wiki/Releases/FeatureTexLive BTW, for the Ubuntu users in the audience, I happened to come across these sites: http://peadrop.com/blog/2007/01/06/pretty-emacs/ http://debs.peadrop.com/dists/edgy/backports/ HTH, Marc __ R-help@stat.math.ethz.ch 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] simple q: returning a logical vector of substring matches
I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a - c(apple, pear) and I want a logical vector of whether each of these strings contains ear (in this case, F T). What is the idiom? Quizzically, Mark Lindeman __ R-help@stat.math.ethz.ch 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] simple q: returning a logical vector of substring matches
You can try the following: a == grep(ear, a, value=T) -Christos Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 400 West Cummings Park Suite 5350 Woburn, MA 01801 Tel: 781-938-3830 www.nuverabio.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Saturday, January 20, 2007 1:31 PM To: r-help@stat.math.ethz.ch Subject: [R] simple q: returning a logical vector of substring matches I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a - c(apple, pear) and I want a logical vector of whether each of these strings contains ear (in this case, F T). What is the idiom? Quizzically, Mark Lindeman __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals and back
Hi, I apologize if there is a simple answer to this question that I've missed. I did search the mailing list but I might not have used the right keywords. Why does sum(A3^2) give the result of 1, but sum(A3^2)==1 give the result of FALSE? A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) A3 [,1] [1,] 0.7071068 [2,] 0.7071068 [3,] 0.000 sum(A3^2) [1] 1 sum(A3^2)^.5 [1] 1 sum(A3^2)==1 # here's the part I don't understand [1] FALSE sum(A3^2)^.5==1 # here's the part I don't understand [1] FALSE I realize that it has something to do with the conversion of the square roots into decimals. But shouldn't it then give me some number other than 1 as the result for sum(A3^2)? Are there other ways to do this than what I've tried? I'm trying to confirm that A3 is a unit vector. Thank you for your help. Bob B. __ R-help@stat.math.ethz.ch 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] simple q: returning a logical vector of substring matches
On Sat, 2007-01-20 at 13:30 -0500, [EMAIL PROTECTED] wrote: I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a - c(apple, pear) and I want a logical vector of whether each of these strings contains ear (in this case, F T). What is the idiom? Quizzically, Mark Lindeman See ?grep and ?regexp a - c(apple, pear) grep(ear, a) [1] 2 grep(ear, a, value = TRUE) [1] pear If you actually want the answer to be FALSE TRUE, then: a %in% grep(ear, a, value = TRUE) [1] FALSE TRUE In that case see ?%in% HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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] Offtopic: emacs 23, was kate editor for R
Ramon Diaz-Uriarte wrote: Hi Marc, Thanks a lot for the detailed explanation! I'll give it a try. (But still, why emacs23? what is missing in v. 21 that you get in 23?). Best, R. Ability to load files with UTF-8 characters in the name? (This is pretty maddening if you find yourself with such a beast.) BTW, any inkling when/whether this is heading for Fedora N? __ R-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals and back
On Sat, 2007-01-20 at 14:00 -0500, Robert Barber wrote: Hi, I apologize if there is a simple answer to this question that I've missed. I did search the mailing list but I might not have used the right keywords. Why does sum(A3^2) give the result of 1, but sum(A3^2)==1 give the result of FALSE? A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) A3 [,1] [1,] 0.7071068 [2,] 0.7071068 [3,] 0.000 sum(A3^2) [1] 1 sum(A3^2)^.5 [1] 1 sum(A3^2)==1# here's the part I don't understand [1] FALSE sum(A3^2)^.5==1 # here's the part I don't understand [1] FALSE I realize that it has something to do with the conversion of the square roots into decimals. But shouldn't it then give me some number other than 1 as the result for sum(A3^2)? Are there other ways to do this than what I've tried? I'm trying to confirm that A3 is a unit vector. Thank you for your help. Bob B. See R FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f print(sum(A3^2)^.5, 20) [1] 0.99988898 HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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] simple q: returning a logical vector of substring matches
try 'regexpr' a - c(apple, pear) regexpr('ear',a)!=-1 [1] FALSE TRUE On 1/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a - c(apple, pear) and I want a logical vector of whether each of these strings contains ear (in this case, F T). What is the idiom? Quizzically, Mark Lindeman __ R-help@stat.math.ethz.ch 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals and back
Thank you very much. That was what I needed to know. Bob B. __ R-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals and back
Hi Robert, does this help? http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) sum(A3^2)==1 all.equal(sum(A3^2), 1) Cheers, Andrew On Sat, Jan 20, 2007 at 02:00:18PM -0500, Robert Barber wrote: Hi, I apologize if there is a simple answer to this question that I've missed. I did search the mailing list but I might not have used the right keywords. Why does sum(A3^2) give the result of 1, but sum(A3^2)==1 give the result of FALSE? A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) A3 [,1] [1,] 0.7071068 [2,] 0.7071068 [3,] 0.000 sum(A3^2) [1] 1 sum(A3^2)^.5 [1] 1 sum(A3^2)==1# here's the part I don't understand [1] FALSE sum(A3^2)^.5==1 # here's the part I don't understand [1] FALSE I realize that it has something to do with the conversion of the square roots into decimals. But shouldn't it then give me some number other than 1 as the result for sum(A3^2)? Are there other ways to do this than what I've tried? I'm trying to confirm that A3 is a unit vector. Thank you for your help. Bob B. __ R-help@stat.math.ethz.ch 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. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@stat.math.ethz.ch 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] simple q: returning a logical vector of substring matches
Using the builtin month.abb try this: regexpr(ov, month.abb) 0 Although not needed here, if ov were a character string that could have special characters such as . and * that have special meaning in a regular expression then do this to prevent such interpretation: regexpr(ov, month.abb, fixed = TRUE) 0 See ?regexpr On 1/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm a relative R novice, and sometimes the simple things trip me up. Suppose I have a - c(apple, pear) and I want a logical vector of whether each of these strings contains ear (in this case, F T). What is the idiom? Quizzically, Mark Lindeman __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals
On 20-Jan-07 Robert Barber wrote: Hi, I apologize if there is a simple answer to this question that I've missed. I did search the mailing list but I might not have used the right keywords. Why does sum(A3^2) give the result of 1, but sum(A3^2)==1 give the result of FALSE? A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) A3 [,1] [1,] 0.7071068 [2,] 0.7071068 [3,] 0.000 sum(A3^2) [1] 1 sum(A3^2)^.5 [1] 1 sum(A3^2)==1 # here's the part I don't understand [1] FALSE sum(A3^2)^.5==1 # here's the part I don't understand [1] FALSE I realize that it has something to do with the conversion of the square roots into decimals. But shouldn't it then give me some number other than 1 as the result for sum(A3^2)? Are there other ways to do this than what I've tried? I'm trying to confirm that A3 is a unit vector. This is an instance of what must be a candidate for the MFAQAT (most frequently asked qustion of all time). The nub of the matter can be found in FAQ 7.31: http://www.r-project.org/ -- FAQs where, at 7.31, it says: 7.31 Why doesn't R think these numbers are equal? The only numbers that can be represented exactly in R's numeric type are integers and fractions whose denominator is a power of 2. Other numbers have to be rounded to (typically) 53 binary digits accuracy. As a result, two floating point numbers will not reliably be equal unless they have been computed by the same algorithm, and not always even then. For example R a - sqrt(2) R a * a == 2 [1] FALSE R a * a - 2 [1] 4.440892e-16 The function all.equal() compares two objects using a numeric tolerance of .Machine$double.eps ^ 0.5. If you want much greater accuracy than this you will need to consider error propagation carefully. For more information, see e.g. David Goldberg (1991), What Every Computer Scientist Should Know About Floating-Point Arithmetic, ACM Computing Surveys, 23/1, 5-48, also available via http://docs.sun.com/source/806-3568/ncg_goldberg.html. However, what this FAQ does not point out is that == tests for exact equality, and even the 'help' page ?== is not as explicit about this: For numerical values, remember '==' and '!=' do not allow for the finite representation of fractions, nor for rounding error. Using 'all.equal' with 'identical' is almost always preferable. See the examples. Nor does the help ?all.equal give the explanation: 'all.equal(x,y)' is a utility to compare R objects 'x' and 'y' testing near equality. ... and a user who is not aware of the imprecision problems inherent in computer arithmetic may well not see the point of testing for near equality when the user expects exact equality mathematically. Statistically speaking, the frequency of occurrence of variants of this question is a phenomenon! I hypothesise that it arises from a combination of two main circumstances: a) Many users who are unfamiliar with the technical details of finite-length binary arithmetic will not be expecting that there could be a problem of this kind in the first place. So, when it occurs, they will simply be puzzled. b) It's actually quite difficult to find your way to the above explanation in the FAQs. First, you need to anticipate that this is the sort of thing that will be a FAQ. If you're subject to (a) above, you may not be thinking on these lines. Secondly, even if you get as far as looking at the FAQs at the above URL, you have a lot of scrolling down to do before you find the question 7.31 Why doesn't R think these numbers are equal? and even then, if you blink you'll miss it: trying it just now, I in fact didn't spot it in the list of questions immediately below the header 7 R Miscellanea even though I already knew it was there somewhere and was actively looking for it. It was only when I landed on the full FAQ itself that I recognised it. It would have been quicker (I just tried that too) to start at the top of the FAQs page, and use the browser's Search tool to search for == : the sixth occurrence of == was it! But, even then, you still need to be thinking that the answer is to be found in connection with ==. If you're subject to (a), you'll be wondering instead why the answer was wrong. This is such a frequently occurring issue that I feel there is a case for a prominently displayed link, maybe in FAQs but maybe better at the top level of r-project.org, to a brief but adequate discourse with a title like Arithmetic [im]precision and apparent errors in R What do others think? Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Jan-07 Time: 19:53:03 -- XFMail --
Re: [R] Error in heatmap()
Dear Yuhong, heatmap deals gracefully with sparse occurences of NA in the matrix, but will fail if whole rows or columns are NA. Try preprocessing your xx as follows: xx = xx[rowSums(!is.na(x))!=0, colSums(!is.na(x))!=0] Best wishes Wolfgang -- Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Hi, I run into following error when using heatmap() for data matrix xx. Any help is appreciated? xx contains many NAs. hv - heatmap(data.matrix(xx)) Error in hclustfun(distfun(if (symm) x else t(x))) : NA/NaN/Inf in foreign function call (arg 11) Thanks a lot. Yuhong __ R-help@stat.math.ethz.ch 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] comparing two matrices
Dear helpeRs, I have two matrices: mat1 - expand.grid(0:2, 0:2, 0:2) mat2 - aa[c(19, 16, 13, 24, 8), ] where mat2 is always a subset of mat1 I need to find the corersponding row numbers in mat1 for each row in mat2. For this I have the following code: apply(mat2, 1, function(x) { which(apply(mat1, 1, function(y) { sum(x == y) }) == ncol(mat1)) }) The code is vectorized, but I wonder if there is a simpler (hence faster) matrix computation that I miss. Thank you, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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] comparing two matrices
Here is a slightly more compact version of your function which might run faster (I did not test timings) since it does not use the sum: apply(mat2, 1, function(x) which(apply(mat1, 1, function(y) all(x == y)) == TRUE)) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Dusa Sent: Saturday, January 20, 2007 5:15 PM To: r-help@stat.math.ethz.ch Subject: [R] comparing two matrices Dear helpeRs, I have two matrices: mat1 - expand.grid(0:2, 0:2, 0:2) mat2 - aa[c(19, 16, 13, 24, 8), ] where mat2 is always a subset of mat1 I need to find the corersponding row numbers in mat1 for each row in mat2. For this I have the following code: apply(mat2, 1, function(x) { which(apply(mat1, 1, function(y) { sum(x == y) }) == ncol(mat1)) }) The code is vectorized, but I wonder if there is a simpler (hence faster) matrix computation that I miss. Thank you, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Insert R logo
Look at the last example in the help for the subplot function in the TeachingDemos package. -Original Message- From: Arun Kumar Saha [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch R-help@stat.math.ethz.ch Sent: 1/20/07 4:35 AM Subject: [R] Insert R logo Dear all R users, I want to insert the R logo in every graphic that I made in my Statistical analysis using R. Can anyone tell me whether is it possible or not and if possible how to do this? your help will be highly appreciated. Thanks and Regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] comparing two matrices
On Sun, 2007-01-21 at 00:14 +0200, Adrian Dusa wrote: Dear helpeRs, I have two matrices: mat1 - expand.grid(0:2, 0:2, 0:2) mat2 - aa[c(19, 16, 13, 24, 8), ] where mat2 is always a subset of mat1 I need to find the corersponding row numbers in mat1 for each row in mat2. For this I have the following code: apply(mat2, 1, function(x) { which(apply(mat1, 1, function(y) { sum(x == y) }) == ncol(mat1)) }) The code is vectorized, but I wonder if there is a simpler (hence faster) matrix computation that I miss. Thank you, Adrian I have not fully tested this, but how about: mat1 - matrix(1:20, ncol = 4, byrow = TRUE) mat2 - matrix(1:60, ncol = 4, byrow = TRUE) mat2 - mat2[sample(15), ] mat1 [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]9 10 11 12 [4,] 13 14 15 16 [5,] 17 18 19 20 mat2 [,1] [,2] [,3] [,4] [1,] 13 14 15 16 [2,]5678 [3,] 41 42 43 44 [4,] 17 18 19 20 [5,] 21 22 23 24 [6,] 25 26 27 28 [7,] 53 54 55 56 [8,]9 10 11 12 [9,] 57 58 59 60 [10,] 33 34 35 36 [11,] 49 50 51 52 [12,] 45 46 47 48 [13,]1234 [14,] 29 30 31 32 [15,] 37 38 39 40 which(apply(matrix(mat2 %in% mat1, dim(mat2)), 1, all)) [1] 1 2 4 8 13 HTH, Marc Schwartz __ R-help@stat.math.ethz.ch 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] Question about converting from square roots to decimals
On Sat, 2007-01-20 at 19:53 +, [EMAIL PROTECTED] wrote: On 20-Jan-07 Robert Barber wrote: Hi, I apologize if there is a simple answer to this question that I've missed. I did search the mailing list but I might not have used the right keywords. Why does sum(A3^2) give the result of 1, but sum(A3^2)==1 give the result of FALSE? A3-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0)) A3 [,1] [1,] 0.7071068 [2,] 0.7071068 [3,] 0.000 sum(A3^2) [1] 1 sum(A3^2)^.5 [1] 1 sum(A3^2)==1 # here's the part I don't understand [1] FALSE sum(A3^2)^.5==1 # here's the part I don't understand [1] FALSE I realize that it has something to do with the conversion of the square roots into decimals. But shouldn't it then give me some number other than 1 as the result for sum(A3^2)? Are there other ways to do this than what I've tried? I'm trying to confirm that A3 is a unit vector. This is an instance of what must be a candidate for the MFAQAT (most frequently asked qustion of all time). The nub of the matter can be found in FAQ 7.31: http://www.r-project.org/ -- FAQs where, at 7.31, it says: 7.31 Why doesn't R think these numbers are equal? The only numbers that can be represented exactly in R's numeric type are integers and fractions whose denominator is a power of 2. Other numbers have to be rounded to (typically) 53 binary digits accuracy. As a result, two floating point numbers will not reliably be equal unless they have been computed by the same algorithm, and not always even then. For example R a - sqrt(2) R a * a == 2 [1] FALSE R a * a - 2 [1] 4.440892e-16 The function all.equal() compares two objects using a numeric tolerance of .Machine$double.eps ^ 0.5. If you want much greater accuracy than this you will need to consider error propagation carefully. For more information, see e.g. David Goldberg (1991), What Every Computer Scientist Should Know About Floating-Point Arithmetic, ACM Computing Surveys, 23/1, 5-48, also available via http://docs.sun.com/source/806-3568/ncg_goldberg.html. However, what this FAQ does not point out is that == tests for exact equality, and even the 'help' page ?== is not as explicit about this: For numerical values, remember '==' and '!=' do not allow for the finite representation of fractions, nor for rounding error. Using 'all.equal' with 'identical' is almost always preferable. See the examples. Nor does the help ?all.equal give the explanation: 'all.equal(x,y)' is a utility to compare R objects 'x' and 'y' testing near equality. ... and a user who is not aware of the imprecision problems inherent in computer arithmetic may well not see the point of testing for near equality when the user expects exact equality mathematically. Statistically speaking, the frequency of occurrence of variants of this question is a phenomenon! I hypothesise that it arises from a combination of two main circumstances: a) Many users who are unfamiliar with the technical details of finite-length binary arithmetic will not be expecting that there could be a problem of this kind in the first place. So, when it occurs, they will simply be puzzled. b) It's actually quite difficult to find your way to the above explanation in the FAQs. First, you need to anticipate that this is the sort of thing that will be a FAQ. If you're subject to (a) above, you may not be thinking on these lines. Secondly, even if you get as far as looking at the FAQs at the above URL, you have a lot of scrolling down to do before you find the question 7.31 Why doesn't R think these numbers are equal? and even then, if you blink you'll miss it: trying it just now, I in fact didn't spot it in the list of questions immediately below the header 7 R Miscellanea even though I already knew it was there somewhere and was actively looking for it. It was only when I landed on the full FAQ itself that I recognised it. It would have been quicker (I just tried that too) to start at the top of the FAQs page, and use the browser's Search tool to search for == : the sixth occurrence of == was it! But, even then, you still need to be thinking that the answer is to be found in connection with ==. If you're subject to (a), you'll be wondering instead why the answer was wrong. This is such a frequently occurring issue that I feel there is a case for a prominently displayed link, maybe in FAQs but maybe better at the top level of r-project.org, to a brief but adequate discourse with a title like Arithmetic [im]precision and apparent errors in R What do others think? Ted. Ted, I think in Robert's case, and perhaps in others as well, there are two confounding issues. The first is the issue that
[R] Can we do GLM on 2GB data set with R?
We are wanting to use R instead of/in addition to our existing stats package because of it's huge assortment of stat functions. But, we routinely need to fit GLM models to files that are approximately 2-4GB (as SQL tables, un-indexed, w/tinyint-sized fields except for the response weight variables). Is this feasible, does anybody know, given sufficient hardware, using R? It appears to use a great deal of memory on the small files I've tested. I've read the data import, memory.limit, memory.size general documentation but can't seem to find a way to tell what the boundaries are roughly gauge the needed memory...other than trial error. I've started by testing the data.frame run out of memory on my PC. I'm new to R so please be forgiving if this is a poorly-worded question. Jill Willie Open Seas Safeco Insurance [EMAIL PROTECTED] 206-545-5673 __ R-help@stat.math.ethz.ch 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] importing selected rows and columns from text
I read through the import/export manual a few times and did not see this mentioned and checked the archives as well. I am dealing with data sheets generated by Eprime (a software package for generating experimental psychology paradigms) that output subject responses in a proprietary Edat file format. All individual subject response spread sheets can be merged to form one long file of all subjects. As an example, if an experiment has 240 responses per subject (120 for each condition, say), each subject will generate a spreadsheet with 240 rows. After merging 10 subjects then, a merged spreadsheet will have 2400 rows, with each subject's responses starting every 240 rows. Formally being an SPSS user, I would do a datalist command that would pick out the columns and rows of interest, and using a rows command, indicate how many rows were equal to one subject. Is there an equivalent way to do this directly from a text file to import into R? That is, give R one long spread sheet composed of all subjects' responses, tell R how many rows make up a subject, which rows make up a discrete condition, and import and flag only the data that I need, and then organize these as discrete variables so that each subject will have 240 columns of responses and only one row (instead of 240 rows and one column as in the original text file). Sorry for the long-winded email, and thanks in advance for any help on this. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] for loop problem
Hello R users, A beginners question which I could not find the answer to in earler posts. My thought process: Here z is a 119 x 15 data matrix Step 1: start at column one, bind every column with column 1 Step2: use the new matrix, test, in the fitCopula package Step3: store each result in myfit, bind each result to answer Step4: return answer copula_est - function(z) { for(i in 1:length(z[1,])) { my.cop - normalCopula(param = 0.5, dim = 2) test - cbind(z[,1],z[,i]) myfit[i] - fitCopula(test,my.cop, start=0.3) } answer - cbind(myfit[i]) return(answer) } Errors received: Error: object test not found Could my syntax be incorrect, or is it a deeper faulty logic error. Thank you for your help, it is much appreciated. aat -- View this message in context: http://www.nabble.com/for-loop-problem-tf3047849.html#a8472217 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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] Working with a set of matrices
Hi, I have a set of matrices (MAT.1, MAT.2, ...) and I'd like to perform the same operation on each of them (for simplicity, say . I'm writing a function for this so that it can be repeated for different sets with different numbers of matrices. The matrices have the same number of columns, but do not have the same number of rows. My thought is to loop thru the set. but I'm not sure how to set the loop up so that the matrix number changes for each cycle. I have tried paste, but that leaves quotation marks around the matrix name (e.g., MAT.1, and I need just MAT.1), or at least the way I'm using paste.. Any thoughts? If there is a better way than the loop, then I'm of course open to that. Thanks in advance. No need to miss a message. Get email on-the-go [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.