[Rd] Suggestion: Adding quick rowMin and rowMax functions to base package
Hi, I wonder whether similarly to the very quick rowSums and colSums functions in the base package, one could add quick functions that calculate the min or max over rows / cols in a matrix. While apply(x,1,min) works, I found out by profiling a program of mine that it is rather slow for matrices with a very large number of rows. A quick functionality seems to be already there in the functions pmax and pmin, but it is rather cumbersume to apply them to all columns of a matrix (if one does not know how many columns the matrix has). Below, I have some code that shows a very unelegant implementation that illustrates possible speed gains if apply could be avoided: rowMin = function(x) { # Construct a call pmin(x[,1],x[,2],...x[,NCOL(x)]) code = paste("x[,",1:(NCOL(x)),"]",sep="",collapse=",") code = paste("pmin(",code,")") return(eval(parse(text=code))) } # Speed comparison: Taking rowMin of a 1,000,000 x 10 matrix x = matrix(rnorm(1e7),1e6,10) # The traditional apply method y=apply(x,1,min) # Runtime ca. 12 seconds # My unelegant rowMin function z=rowMin(x) # Runtime ca 0.5 seconds Of course, the way the function rowMin is constructed is highly ineffective if the matrix x has many columns, but maybe there is a simple way to adapt the code from pmin and pmax to create quick rowMin, rowMax,... functions. I don't know whether it is worth the effort, but I guess taking minima and maxima over rows is a common task. Best wishes, Sebastian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Small typo in abline.R
On Mon, 29 Mar 2010, Stephen Weigand wrote: I found a small typo in abline.R where the line: warning("only using the first two of ",p, "regression coefficients") should have a space before the word 'regression'. Thank you, but this should really be (for translation purposes) warning(gettextf("only using the first two of %d regression coefficients", p), domain = NA) and messages are frozen in pre-2.11.0 as we are in the translation window. So the correction won't appear for a while. Thanks, Stephen __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Small typo in abline.R
I found a small typo in abline.R where the line: warning("only using the first two of ",p, "regression coefficients") should have a space before the word 'regression'. Thanks, Stephen __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Using SVN + SSH on windows
Paul Gilbert wrote: ... I try several things: if I do 'svn://christo...@svn.r-forge.r-project.org/svnroot/kml3d', I do manage to download the project. But then, I do not manage to upload some modification. All looks ok, but I think you are using the wrong protocol. It should be 'svn+ssh' for *commits*, i.e. svn+ssh://christo...@svn.r-forge.r-project.org/svnroot/kml3d ... (If this was already mentioned I missed it.) If you first check out with svn:// I find it relatively difficult to commit using a different protocol. It may be possible, but, if you intend to commit, I think it is much easier if you check out using svn+ssh:// so you can then commit without specifying the protocol. As others mention, to simplify you can get the checkout and commit working without a key and pageant first. It is pretty solid once it is working. An alternative not yet mentioned in this thread would be to use an IDE which offers strong svn support (such as Eclipse + Subclipse). If one remembers to configure it to use the pure Java (SVNKit) interface, it works well with R-Forge on many platforms (including Windows). Best, Tobias __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Using SVN + SSH on windows
... >> I try several things: if I do >> 'svn://christo...@svn.r-forge.r-project.org/svnroot/kml3d', I do >manage to >> download the project. But then, I do not manage to upload some >modification. > >All looks ok, but I think you are using the wrong protocol. It should >be 'svn+ssh' for *commits*, i.e. > >svn+ssh://christo...@svn.r-forge.r-project.org/svnroot/kml3d ... (If this was already mentioned I missed it.) If you first check out with svn:// I find it relatively difficult to commit using a different protocol. It may be possible, but, if you intend to commit, I think it is much easier if you check out using svn+ssh:// so you can then commit without specifying the protocol. As others mention, to simplify you can get the checkout and commit working without a key and pageant first. It is pretty solid once it is working. Paul La version française suit le texte anglais. This email may contain privileged and/or confidential information, and the Bank of Canada does not waive any related rights. Any distribution, use, or copying of this email or the information it contains by other than the intended recipient is unauthorized. If you received this email in error please delete it immediately from your system and notify the sender promptly by email that you have done so. Le présent courriel peut contenir de l'information privilégiée ou confidentielle. La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion, utilisation ou copie de ce courriel ou des renseignements qu'il contient par une personne autre que le ou les destinataires désignés est interdite. Si vous recevez ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre ordinateur toute copie du courriel reçu. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] .Call and .C arguments
On Mon, Mar 29, 2010 at 01:56:14PM +0200, Roger Bergande wrote: ... > The passed values are not the same in C. I 'm calling a function in C > with the argument as.double(1204.245) but in the debug mode in C the > value has changed to 1204.2449. I do not see this value printed in the examples below. So, i think you assume that 1204.245 was changed to 1204.2449 since rounding it to 2 digits produces 1204.24. The problem is indeed a rounding problem, but not when the number is passed to C. The number 1204.245 cannot be represented in double precision exactly. So, already at the R level is, actually formatC(1204.245, digits=20) # [1] "1204.24498909" See http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy or FAQ 7.31 for more examples. Petr Savicky. > > Is there a way to pass the arguments differently? > > > > I'm using Windows and Visual Studio C++ 2005 Express Edition and > R-2.10.1. > > > > > > Please see the two simple examples to understand the issue. > > > > # C call from R > > .C("myroundC",as.double(1204.245)) > > > > > > // C Code > > > > void myroundC(double *Amount){ > > > > *Amount = Rf_fround(*Amount,2); > > > > } > > > > #Return value in R > > [[1]] > > [1] 1204.24 > > > > > > > > # C call from R > > .Call("myroundCall",as.double(1204.245)) > > > > // C Code > > SEXP myroundCall(SEXP a){ > > double *ap = REAL(a), *ansp; > > SEXP ans; > > PROTECT(ans = allocVector(REALSXP, 1)); > > ansp = REAL(ans); > > *ansp = Rf_fround(*ap,2); > > UNPROTECT(1); > > return(ans); > > } > > > > #Return value in R > > [1] 1204.24 > > > > # expected value 1204.25 > > > > > > Thanks a lot for your help. > > Best regards > > Roger Bergande > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] .Call and .C arguments
Thank you Ducan I'm sorry I wasen't thinking about floating point arithmetic. My problem has nothing to do with the interface. Same rounding in R directly.. Thanks for the hint. Roger __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] .Call and .C arguments
On 29/03/2010 7:56 AM, Roger Bergande wrote: -- Forwarded message -- From: roger.berga...@swisslife.ch Date: Mon, 29 Mar 2010 13:51:12 +0200 Subject: .Call and .C arguments To: berga...@gmail.com Dear List My question is about .C and .Call I was experimenting with the .C and .Call interface as I came across the following behaviour. The passed values are not the same in C. I 'm calling a function in C with the argument as.double(1204.245) but in the debug mode in C the value has changed to 1204.2449. What makes you think those two numbers are different? See FAQ 7.31. Duncan Murdoch Is there a way to pass the arguments differently? I'm using Windows and Visual Studio C++ 2005 Express Edition and R-2.10.1. Please see the two simple examples to understand the issue. # C call from R .C("myroundC",as.double(1204.245)) // C Code void myroundC(double *Amount){ *Amount = Rf_fround(*Amount,2); } #Return value in R [[1]] [1] 1204.24 # C call from R .Call("myroundCall",as.double(1204.245)) // C Code SEXP myroundCall(SEXP a){ double *ap = REAL(a), *ansp; SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); ansp = REAL(ans); *ansp = Rf_fround(*ap,2); UNPROTECT(1); return(ans); } #Return value in R [1] 1204.24 # expected value 1204.25 Thanks a lot for your help. Best regards Roger Bergande __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] .Call and .C arguments
-- Forwarded message -- From: roger.berga...@swisslife.ch Date: Mon, 29 Mar 2010 13:51:12 +0200 Subject: .Call and .C arguments To: berga...@gmail.com Dear List My question is about .C and .Call I was experimenting with the .C and .Call interface as I came across the following behaviour. The passed values are not the same in C. I 'm calling a function in C with the argument as.double(1204.245) but in the debug mode in C the value has changed to 1204.2449. Is there a way to pass the arguments differently? I'm using Windows and Visual Studio C++ 2005 Express Edition and R-2.10.1. Please see the two simple examples to understand the issue. # C call from R .C("myroundC",as.double(1204.245)) // C Code void myroundC(double *Amount){ *Amount = Rf_fround(*Amount,2); } #Return value in R [[1]] [1] 1204.24 # C call from R .Call("myroundCall",as.double(1204.245)) // C Code SEXP myroundCall(SEXP a){ double *ap = REAL(a), *ansp; SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); ansp = REAL(ans); *ansp = Rf_fround(*ap,2); UNPROTECT(1); return(ans); } #Return value in R [1] 1204.24 # expected value 1204.25 Thanks a lot for your help. Best regards Roger Bergande __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Using SVN + SSH on windows
Christophe, if you want to solve your problem, please see if you first can do it *without* ssh-keys. *Only* when that is working, worry about the ssh keys. For detailed information on both cases, see by Thread '[Rd] Setting up TortoiseSVN and PuTTY on Windows for r-forge.r-project.org' on 2010-03-28. /Henrik On Sun, Mar 28, 2010 at 5:45 AM, David Scott wrote: > Uwe Ligges wrote: >> >> It is really not hard to set it up. I am using a vanilla ssh (rather than >> putty) and that works fine all the time... >> >> Uwe Ligges > > > Ditto here. I am using ssh non commercial version with tortoise on Vista, > and I don't recall any problems setting it up. R-forge works perfectly fine > with windows and tortoise in my experience. > > Is your putty/ssh working? Can you access other machines with it? I do > recall ssh can be a bit fussy. > > David Scott > >> >> >> On 27.03.2010 18:31, Gabor Grothendieck wrote: >>> >>> s getting commits to R-Forge to work from >>> Windows. The entire system is really geared to UNIX. It took me a >>> couple of days of trial and error (since you have to wait 20 minutes >>> for each try) before I got it working. Although I did get it to work, >>> I ultimately decided to host all my packages on googlecode. >>> googlecode is extremely easy to use from Windows and does not require >>> any public/private key, pageant, etc. e.g. >>> http://sqldf.googlecode.com. If you already have TortoiseSVN and know >>> how to use it then you can probably set up a googlecode site in >>> literally 5 minutes. >>> >>> One other possibility. I think there is a way to host your project on >>> googlecode but still have it mirrored on R-forge so from your users' >>> viewpoint its the same as if it were on R-Forge but you can use the >>> simpler googlecode site. In that case you might not need to set up >>> commits on R-Forge since you would do all your commits through >>> googlecode (depending on how it works) but I have not seen good >>> documentation on how to do this. >>> >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > > > -- > _ > David Scott Department of Statistics > The University of Auckland, PB 92019 > Auckland 1142, NEW ZEALAND > Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 > Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 > > Director of Consulting, Department of Statistics > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Possible improvements/clarifications for R-forge (Was: Re: Using SVN + SSH on windows)
On Mon, Mar 29, 2010 at 12:15 PM, wrote: > >> Getting back to the original poster who may have been forgotten in all >> this, alternatives are switching to Linux and using R-Forge with that >> (if such a switch in platforms is feasible) or using googlecode >> (that's the largest repository of R projects outside of CRAN with 237 >> R projects listed -- it uses https rather than ssh which eliminates >> all the problems). > > Naive question: Is it not possible to make R-forge works either with ssh or > with https? AFAIK, no - see Point 5 in my initial post in this thread ('[Rd] Possible improvements/clarifications for R-forge'; 2010-03-28). /Henrik > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Possible improvements/clarifications for R-forge (Was: Re: Using SVN + SSH on windows)
Getting back to the original poster who may have been forgotten in all this, alternatives are switching to Linux and using R-Forge with that (if such a switch in platforms is feasible) or using googlecode (that's the largest repository of R projects outside of CRAN with 237 R projects listed -- it uses https rather than ssh which eliminates all the problems). Naive question: Is it not possible to make R-forge works either with ssh or with https? __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel