Re: [Rd] branch cuts in atan(), asin(), acos() (PR#7871)
On Mon, 16 May 2005 [EMAIL PROTECTED] wrote: The complex versions of atain(), asin(), acos() are not documented except in the source code. Thank you, but your patch does not address that so they would become undocumented (they no longer follow the comment in the source code, which BTW is regarded as documentation). Could you please supply documentation to match this change, including the exact definition you have implemented. Also: have you looked at atan2? The branch cuts that are implemented do not tally with those of Abramowitz and Stegun, figure 4.4, p79. The current branch cuts appear to be inherited from sqrt() and log(), in a non-obvious manner. Also, the current behaviour of atan() leads to the following: R tan(atan(2)) [1] 2 R tan(atan(2+0i)) [1] -0.5+0i (I would expect a value close to 2 in both these) R atan(2) [1] 1.107149 R atan(2+0i) [1] -0.4636476+0i (I would expect these two expressions to evaluate to numbers with small absolute difference) atan(1.0001+0i) [1] -0.7853482+0i atan(0.+0i) [1] 0.7853482+0i (I would expect these two expressions to evaluate to numbers with small absolute difference) The following patch to src/main/complex.c appears to implement the desired behaviour: octopus:~/downloads/R-2.1.0/src/main% diff -c complex.c /Users/rksh/unix/rksh/complex.c *** complex.c Mon Apr 18 22:30:00 2005 --- /Users/rksh/unix/rksh/complex.c Mon May 16 14:33:15 2005 *** *** 367,372 --- 367,376 bet = t1 - t2; r-r = asin(bet); r-i = log(alpha + sqrt(alpha*alpha - 1)); + + if(y0){ + r-i *= -1; + } } static void z_acos(Rcomplex *r, Rcomplex *z) *** *** 388,393 --- 392,404 r-r = 0.5 * atan(2 * x / ( 1 - x * x - y * y)); r-i = 0.25 * log((x * x + (y + 1) * (y + 1)) / (x * x + (y - 1) * (y - 1))); + + if((x*x+y*y 1) x0){ + r-r += M_PI_2; + } + if((x*x+y*y 1) x0){ + r-r -= M_PI_2; + } } static void z_atan2(Rcomplex *r, Rcomplex *csn, Rcomplex *ccs) octopus:~/downloads/R-2.1.0/src/main% -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] locator() (PR#7873)
[EMAIL PROTECTED] wrote: Full_Name: Sascha Frydman Version: 2.1.0 OS: Windows XP Submission from: (NULL) (147.66.131.10) when Esc is pressed while a plot with locator running has the focus, R crashes. eg. plot(1) locator(1) I am running in SDI mode I see this too. I'll track it down. Duncan Murdoch __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] locator() (PR#7873)
[EMAIL PROTECTED] wrote: Full_Name: Sascha Frydman Version: 2.1.0 OS: Windows XP Submission from: (NULL) (147.66.131.10) when Esc is pressed while a plot with locator running has the focus, R crashes. eg. plot(1) locator(1) I am running in SDI mode Thanks for the report. This is fixed now in the patched version. It should show up in the snapshot builds on CRAN by tomorrow. Duncan Murdoch __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] branch cuts in atan(), asin(), acos() (PR#7871)
On May 17, 2005, at 07:01 am, Prof Brian Ripley wrote: On Mon, 16 May 2005 [EMAIL PROTECTED] wrote: The complex versions of atain(), asin(), acos() are not documented except in the source code. Thank you, but your patch does not address that so they would become undocumented (they no longer follow the comment in the source code, which BTW is regarded as documentation). Could you please supply documentation to match this change, including the exact definition you have implemented. Also: have you looked at atan2? OK, this follows PR#7871, discussing branch cuts of inverse trig functions. In this email, I provide a context diff between complex.c (R-2.1.0) and a version that moves the branch cuts to the standard places. The changes are documented in the code. I also give updated Trig.Rd and Hyperbolic.Rd files which document the behaviour of the new functions. R-2.1.0 passes make check with the new files (after editing Rdutils.Rd, which caused a problem). I have not attempted to alter z_atan2(): there appear to be unrelated issues here. For example, atan2(0,0) gives 0 as documented, but atan2(0i,0i) gives NA. Also, atan2(0,1i) returns an error (I would expect a zero here too). I feel it is better to consider z_atan2() as a separate issue. I will file a separate bugreport for this. diff -c old complex.c new complex.c *** /Users/rksh/downloads/R-2.1.0/src/main/complex.cMon Apr 18 22:30:00 2005 --- complex.c Tue May 17 13:35:27 2005 *** *** 355,360 --- 355,365 /* Complex Arcsin and Arccos Functions */ /* Equation (4.4.37) Abramowitz and Stegun */ + /* with additional terms to force the branch + /* to agree with figure 4.4, p79. Continuity */ + /* on the branch cuts (real axis; y==0, |x| 1) is */ + /* standard: z_asin() is continuous from below if x = 1 */ + /* and continuous from above if x = -1. */ static void z_asin(Rcomplex *r, Rcomplex *z) { *** *** 367,372 --- 372,382 bet = t1 - t2; r-r = asin(bet); r-i = log(alpha + sqrt(alpha*alpha - 1)); + + if(y0 || (y==0 x 1)){ + r-i *= -1; + } + } static void z_acos(Rcomplex *r, Rcomplex *z) *** *** 379,384 --- 389,399 /* Complex Arctangent Function */ /* Equation (4.4.39) Abramowitz and Stegun */ + /* with additional terms to force the branch cuts */ + /* to agree with figure 4.4, p79. Continuity */ + /* on the branch cuts (pure imaginary axis; x==0, |y|1) */ + /* is standard: z_asin() is continuous from the right */ + /* if y = 1, and continuous from the left if y = -1. */ static void z_atan(Rcomplex *r, Rcomplex *z) { *** *** 388,393 --- 403,416 r-r = 0.5 * atan(2 * x / ( 1 - x * x - y * y)); r-i = 0.25 * log((x * x + (y + 1) * (y + 1)) / (x * x + (y - 1) * (y - 1))); + + if(x*x + y*y 1){ + r-r += M_PI_2; + if(x 0 || (x==0 y0)){ + r-r -= M_PI; + } + } + } static void z_atan2(Rcomplex *r, Rcomplex *csn, Rcomplex *ccs) FILE Hyperbolic.Rd STARTS \name{Hyperbolic} \title{Hyperbolic Functions} \usage{ cosh(x) sinh(x) tanh(x) acosh(x) asinh(x) atanh(x) } \alias{cosh} \alias{sinh} \alias{tanh} \alias{acosh} \alias{asinh} \alias{atanh} \description{ These functions give the obvious hyperbolic functions. They respectively compute the hyperbolic cosine, sine, tangent, and their inverses, arc-cosine, arc-sine, arc-tangent (or \dQuote{\emph{area cosine}}, etc). } \arguments{ \item{x}{a numeric or complex vector} } \details{ These are generic functions: methods can be defined for them individually or via the \code{\link{Math}} group generic. Branch cuts are consistent with the inverse trigonometric functions \code{asin()} et seq, and agree with those defined in Abramowitz and Stegun, figure 4.7, page 86. } \seealso{ The trigonometric functions, \code{\link{cos}}, \code{\link{sin}}, \code{\link{tan}}, and their inverses \code{\link{acos}}, \code{\link{asin}}, \code{\link{atan}}. The logistic distribution function \code{\link{plogis}} is a shifted version of \code{tanh()}. } \keyword{math} FILE Hyperbolic.Rd ENDS File Trig.Rd STARTS \name{Trig} \alias{Trig} \alias{cos} \alias{sin} \alias{tan} \alias{acos} \alias{asin} \alias{atan} \alias{atan2} \title{Trigonometric Functions} \description{ These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent, and the two-argument arc-tangent. } \usage{ cos(x) sin(x) tan(x) acos(x) asin(x) atan(x) atan2(y, x) } \arguments{ \item{x, y}{numeric or complex vector} } \details{ The arc-tangent of two arguments \code{atan2(y,x)} returns the angle between the x-axis and the vector from the origin to
[Rd] install.packages Bug? (PR#7876)
Full_Name: Martin Posch Version: 2.1.0 and 2.1.0 patched OS: Windows XP SP2 Submission from: (NULL) (131.130.1.135) When installing the Hmisc package using the install option in the RGUI I get the error message under both R 2.1.0 and R 2.1.0 patched (see the outputs below). I tried the install after a fresh reboot (to minimize the possibility of locked up files). The same problem arises with some of the other packages. I use a german Windows version but set the RGUI-language to english (setting the environment variable LC_all to en. * R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.0 (2005-04-18), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.1/Hmisc_3.0-5.zip' Content type 'application/zip' length 1954673 bytes opened URL downloaded 1908Kb package 'Hmisc' successfully unpacked and MD5 sums checked Error in sprintf(gettext(unable to move temp installation '%d' to '%s'), : use format %s for character objects ** R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.0 Patched (2005-05-14), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.1/Hmisc_3.0-5.zip' Content type 'application/zip' length 1954673 bytes opened URL downloaded 1908Kb package 'Hmisc' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Dokumente und Einstellungen\Admin\Lokale Einstellungen\Temp\Rtmp20068\downloaded_packages updating HTML package descriptions Warning message: unable to move temp installation 'C:/Programme/R/rw2010pat/library\file29532/Hmisc' to 'C:/Programme/R/rw2010pat/library/Hmisc' __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] returning an empty list.
I would like to return an empty list from a C function. This I would do as: if (file.exists()) { /* do something */ } else { SEXP empty_list; PROTECT(empty_list = NEW_LIST(0)); UNPROTECT(1); return empty_list; } The PROTECT, UNPROTECT lines seemed like overkill to me, but as far as I understood the documentation this seemed like the correct usage. It seems like I could really just do the following: return NEW_LIST(0); but I thought I'd better ask first. Thanks in advance, I hope I did not miss something in the documentation which describes this. Thanks, jim -- James Bullard [EMAIL PROTECTED] 760.267.0986 __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] returning an empty list.
James Bullard wrote: I would like to return an empty list from a C function. This I would do as: if (file.exists()) { /* do something */ } else { SEXP empty_list; PROTECT(empty_list = NEW_LIST(0)); UNPROTECT(1); return empty_list; } The PROTECT, UNPROTECT lines seemed like overkill to me, but as far as I understood the documentation this seemed like the correct usage. It seems like I could really just do the following: return NEW_LIST(0); but I thought I'd better ask first. Thanks in advance, I hope I did not miss something in the documentation which describes this. You can use the short form in this case. You need to PROTECT an SEXP whenever you do further operations that may trigger a garbage collection but in this case there are no such further operations. Depending on what you are going to do with the returned value it may be simpler to use return R_NilValue; which returns NULL. __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] install.packages Bug? (PR#7876)
This is a Windows error message, not an R error. Do you have some pre-existing installation in that directory? It is not something we can reproduce. The 2.1.0 message bug was fixed a while back. On Tue, 17 May 2005 [EMAIL PROTECTED] wrote: Full_Name: Martin Posch Version: 2.1.0 and 2.1.0 patched OS: Windows XP SP2 Submission from: (NULL) (131.130.1.135) When installing the Hmisc package using the install option in the RGUI I get the error message under both R 2.1.0 and R 2.1.0 patched (see the outputs below). I tried the install after a fresh reboot (to minimize the possibility of locked up files). The same problem arises with some of the other packages. I use a german Windows version but set the RGUI-language to english (setting the environment variable LC_all to en. * R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.0 (2005-04-18), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.1/Hmisc_3.0-5.zip' Content type 'application/zip' length 1954673 bytes opened URL downloaded 1908Kb package 'Hmisc' successfully unpacked and MD5 sums checked Error in sprintf(gettext(unable to move temp installation '%d' to '%s'), : use format %s for character objects ** R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.0 Patched (2005-05-14), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.1/Hmisc_3.0-5.zip' Content type 'application/zip' length 1954673 bytes opened URL downloaded 1908Kb package 'Hmisc' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Dokumente und Einstellungen\Admin\Lokale Einstellungen\Temp\Rtmp20068\downloaded_packages updating HTML package descriptions Warning message: unable to move temp installation 'C:/Programme/R/rw2010pat/library\file29532/Hmisc' to 'C:/Programme/R/rw2010pat/library/Hmisc' __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problem with limmaGUI (PR#7877)
Full_Name: Edoardo Giacopuzzi Version: 2.0.1 OS: Windows XP Home Submission from: (NULL) (80.181.65.157) I have some problem with this new version of R GUI. I've used limmaGUI package with an older version of R and it works perfectlly, but now with the last version R 2.0.1.0 two error boxs appear every time I try to launch this package: 1. Error in list.files(path, pattern, all.files, full.names, recursive): regular expressione 'pattern' not valid 2. Error in try(expr, TRUE): oggetto source.files not found The package correctly load the grapich interface anyway, but I've experimented some problems when I try to load my .gpr files for analysis: the program often crash! Thanks. __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem with limmaGUI (PR#7877)
Hello, The first error message is the kind of error that appears due to some changes in grep() and the like in R 2.1.0 and when they are used to test some string issued from Tcl (limmaGUI uses tcltk, isn't it?) I have the same kind of errors with SciViews and have to adjust the code to make it fully compatible with R 2.1.0. I would recommend to contact the package maintainer and ask for an update for version 2.1.0 of R. In the meantime, you should continue to use R 2.0.1 with limmaGUI, if you really need the GUI. Best, Philippe Grosjean ..°})) ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Pentagone (3D08) ( ( ( ( (Academie Universitaire Wallonie-Bruxelles ) ) ) ) ) 8, av du Champ de Mars, 7000 Mons, Belgium ( ( ( ( ( ) ) ) ) ) phone: + 32.65.37.34.97, fax: + 32.65.37.30.54 ( ( ( ( (email: [EMAIL PROTECTED] ) ) ) ) ) ( ( ( ( (web: http://www.umh.ac.be/~econum ) ) ) ) ) http://www.sciviews.org ( ( ( ( ( .. [EMAIL PROTECTED] wrote: Full_Name: Edoardo Giacopuzzi Version: 2.0.1 OS: Windows XP Home Submission from: (NULL) (80.181.65.157) I have some problem with this new version of R GUI. I've used limmaGUI package with an older version of R and it works perfectlly, but now with the last version R 2.0.1.0 two error boxs appear every time I try to launch this package: 1. Error in list.files(path, pattern, all.files, full.names, recursive): regular expressione 'pattern' not valid 2. Error in try(expr, TRUE): oggetto source.files not found The package correctly load the grapich interface anyway, but I've experimented some problems when I try to load my .gpr files for analysis: the program often crash! Thanks. __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Q] Example Data Files for Package
If the example data files for a package are extremely large, should they just be put in a different package specifically for example data? If so, are these data packages normally submitted to CRAN/BioC or mentioned in README with directions specifying where to download on developer site? If these files are all dot-tsv (.tsv), they would seem appropriate for the data directory. Writing R Extensions doesn't specifically mention this as a valid file extension for that directory. Glancing around at some other packages, I see a number that create an 'extdata' directory. Is there a consensus on where alternative data files should be put within a package? -- SIGSIG -- signature too long (core dumped) __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem with limmaGUI (PR#7877)
[EMAIL PROTECTED] wrote: Full_Name: Edoardo Giacopuzzi Version: 2.0.1 OS: Windows XP Home Submission from: (NULL) (80.181.65.157) I have some problem with this new version of R GUI. I've used limmaGUI package with an older version of R and it works perfectlly, but now with the last version R 2.0.1.0 two error boxs appear every time I try to launch this package: 1. Error in list.files(path, pattern, all.files, full.names, recursive): regular expressione 'pattern' not valid 2. Error in try(expr, TRUE): oggetto source.files not found The package correctly load the grapich interface anyway, but I've experimented some problems when I try to load my .gpr files for analysis: the program often crash! You should report problems with contributed packages to the maintainer. Most often they are caused by incompatibilities with something new in R. limmaGUI isn't a package on CRAN, so that's what I'd expect in this case. Duncan Murdoch __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [Q] Example Data Files for Package
Paul: If the example data files for a package are extremely large, What is extremely large here? Mega/giga/terrabytes? should they just be put in a different package specifically for example data? If so, are these data packages normally submitted to CRAN/BioC or mentioned in README with directions specifying where to download on developer site? That depends on the value of extremely large. Up to a certain extent (a few hundred KB or so), I would put them into the package. Otherwise include a README or (maybe even better) a man page that has the example code and explains where to obtain the data. If these files are all dot-tsv (.tsv), they would seem appropriate for the data directory. For large data sets consider to save() the data to .rda to reduce memory usage. Also try the `compress' option. To give you an impression: the spam data set in package kernlab has dimension 4601 x 58 and is 180K in compressed binary format. Writing R Extensions doesn't specifically mention this as a valid file extension for that directory. Glancing around at some other packages, I see a number that create an 'extdata' directory. Is there a consensus on where alternative data files should be put within a package? In most situations, I would recommend to include data just as usual in the data directory. my EUR 0.02 Z __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] bandwidth selection through cross validation in density estimation?
Hi, The density function has a parameter that allows choosing a bandwidth using cross-validaton method, as described here: */'bw.ucv' and 'bw.bcv' implement unbiased and biased cross-validation respectively./**/ /*However, I didn't see any loops in the density function source code. I checked the program bandwidths.c and it looks to me that an optimization function fmin.c is used for bandwidth selection. fmin.c uses the Nelder-Mead search Method, and I don't think this is a cross validation method. I wonder if I have missed any information. Could any one point to me where is the cross validaton implemented for bandwidth selection? Thanks and best regards, Hui [[alternative HTML version deleted]] __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel