[Rd] LazyLoad changes the class of objects
Consider a package that this DESCRIPTION file: --- Package: tester Version: 0.1-0 Date: 2007-10-12 Title: Prototype object-based programming Author: Gabor Grothendieck Maintainer: Gabor Grothendieck [EMAIL PROTECTED] Description: test LazyLoad: true Depends: R (= 2.6.0) License: GPL2 --- and a single subdirectory R containing tester.R which contains two lines: --- e - new.env() class(e) - c(x, environment) --- Now issue these commands: library(tester) class(tester::e) [1] environment R.version.string # Windows Vista [1] R version 2.6.0 Patched (2007-10-08 r43124) Note that the class of e was changed from what we set it to !!! On the other handn, if we omit LazyLoad: true from the DESCRIPTION file then it retains its original class. # removed LazyLoad: true line from DESCRIPTION and reinstall pkg # now its ok library(tester) class(tester::e) [1] x environment __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] as.integer(x) versus as.integer(trunc(x))
as.integer(x) rounds floating point numbers towards zero, so it behaves approximately as as.integer(trunc(x)). If x INT_MAX, then as.integer(x) is NA. This is nothing bad, but it is slightly more restrictive than necessary. An alternative approach could be that as.integer(x) is NA, if trunc(x) INT_MAX and as.integer(x) == INT_MAX for all x in [INT_MAX,INT_MAX+1). Let me suggest the following patch to IntegerFromReal for consideration: --- R-devel_2007-10-11-orig/src/main/coerce.c 2007-07-25 17:54:17.0 +0200 +++ R-devel_2007-10-11-asinteger/src/main/coerce.c 2007-10-12 07:10:06.0 +0200 @@ -173,7 +173,8 @@ { if (ISNAN(x)) return NA_INTEGER; -else if (x INT_MAX || x = INT_MIN ) { +x = trunc(x); +if (x INT_MAX || x = INT_MIN ) { *warn |= WARN_NA; return NA_INTEGER; } This patch changes the behavior as suggested above. Its effect may be seen using the script options(digits=12) x - seq(2^31 - 3, 2^31, length=7) cbind(x,as.integer(trunc(x)),as.integer(x)) Original behavior: [1,] 2147483645.0 2147483645 2147483645 [2,] 2147483645.5 2147483645 2147483645 [3,] 2147483646.0 2147483646 2147483646 [4,] 2147483646.5 2147483646 2147483646 [5,] 2147483647.0 2147483647 2147483647 [6,] 2147483647.5 2147483647 NA [7,] 2147483648.0 NA NA Using the patch: [1,] 2147483645.0 2147483645 2147483645 [2,] 2147483645.5 2147483645 2147483645 [3,] 2147483646.0 2147483646 2147483646 [4,] 2147483646.5 2147483646 2147483646 [5,] 2147483647.0 2147483647 2147483647 [6,] 2147483647.5 2147483647 2147483647 [7,] 2147483648.0 NA NA Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] pt inaccurate when x is close to 0 (PR#9945)
DM == Duncan Murdoch [EMAIL PROTECTED] on Thu, 11 Oct 2007 11:10:49 -0400 writes: DM Here's a contribution from Ian Smith that got bounced DM from the list. [well, given the obvious Spam that AOL appended at the end... ] DM Original Message DM Subject: Re: [Rd] pt inaccurate when x is close to 0 (PR#9945) DM Date: Thu, 11 Oct 2007 06:02:43 -0400 DM From: [EMAIL PROTECTED] DM To: [EMAIL PROTECTED] DM Duncan, DM I tried sending the rest of this to R-devel but it was rejected as spam, DM hence the personal e-mail. DM R calculates the pt value from DM nx = 1 + (x/n)*x; DM val = pbeta(1./nx, n / 2., 0.5, /*lower_tail*/1, log_p); DM whereas Gnumeric calculates the value as DM val =? (n x * x) DM ? pbeta (x * x / (n + x * x), 0.5, n / 2, /*lower_tail*/0, log_p) DM : pbeta (n / (n + x * x), n / 2.0, 0.5, /*lower_tail*/1, log_p); seems a good idea {{however I doubt the ? in val =? above }} DM thus avoiding the loss of accuracy in the pbeta routine when 1-1./nx DM is calculated. DM It also makes the DM if (n 4e5) { /*-- Fixme(?): test should depend on `n' AND `x' ! */ DM ??? /* Approx. from? Abramowitz Stegun 26.7.8 (p.949) */ DM ??? val = 1./(4.*n); DM ??? return pnorm(x*(1. - val)/sqrt(1. + x*x*2.*val), 0.0, 1.0, DM lower_tail, log_p); DM } DM code unneccessary. probably, will have to see. DM Ian Smith DM Personally, I think the code should also guard against the possible DM overflow of the x * x expressions. The current code actually *does* guard since the overflow happens to +Inf and that does fulfill ' 1e100' and the current code has nx = 1 + (x/n)*x; if(fabs(nx) 1e100) { } ... I'll try to use the Gnumeric switch and see and think some more about the other extreme cases. Martin __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] no visible binding
Dear Roger, simply use quotes as in: model.extract(m, response) Best, Uwe roger koenker wrote: Could someone advise me about how to react to the message: * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) X - as.matrix.csr(model.matrix(Terms, m, contrasts)) fit - { if (length(weights)) slm.wfit(X, Y, weights, method, ...) else slm.fit(X, Y, method, ...) } fit$terms - Terms fit$call - call attr(fit, na.message) - attr(m, na.message) class(fit) - c(if (is.matrix(Y)) mslm, slm) fit } url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ 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] Error in Windows Vista, saving workspace...
Do you have write permissions in the current working directory? I guess not. Uwe Ligges Filipe Santos wrote: Dear all... I'm using R 2.6.0 in windows Vista. And I got the following error: quit() Save workspace image? [y/n/c]: y Error in gzfile(file,wb): unable to open connection In addiction: Warning message: In gzfile(file, wb) : cannot open compressed file '.RDataTmp' This happens in both in RGui and Rterm Thanks, Filipe Santos __ 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] Error on saving graphics as ps-files with R 2.6.0 (PR#9960)
[EMAIL PROTECTED] wrote: Full_Name: Johannes Schauer Version: 2.6.0 OS: Windows XP Professional Submission from: (NULL) (129.27.154.7) When I want to save graphics (hist, boxplot, plot, ...) as ps-files in R 2.6.0 I get an error message stating Invalid font type with font family not found in PostScript font database. I used to work with R 2.5.1 and R 2.5.0 and it seems to be a new problem. This has already been fixed in r-patched an reported several times. Please read the NEWS files and the mailing list archives. I am really surprised that so many people are using the menu (and hence copying devices) rather than starting from a clean postscript device (which is always preferable). No developer does so I guess and nobody else seems to have looked into the alpha/beta versions or release candidates of R-2.6.0... Uwe Ligges __ 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] no visible binding
roger koenker wrote: Could someone advise me about how to react to the message: I'd try putting quotes in model.extract(m, response) (and also in model.extract(m, weights) even though you're not seeing the complaint on that one). * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) X - as.matrix.csr(model.matrix(Terms, m, contrasts)) fit - { if (length(weights)) slm.wfit(X, Y, weights, method, ...) else slm.fit(X, Y, method, ...) } fit$terms - Terms fit$call - call attr(fit, na.message) - attr(m, na.message) class(fit) - c(if (is.matrix(Y)) mslm, slm) fit } url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- O__ Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] File-Choose directory-Choose a folder (PR#9959)
As I've noted on the website, this appears to be a Vista bug as the Microsoft example code also fails. Note: choose.dir() works in Rterm but not in Rgui. On Wed, 10 Oct 2007, [EMAIL PROTECTED] wrote: Full_Name: Roberto Passera Version: 2.6.0 and 2.6.0 patched OS: Windows Vista Premium Submission from: (NULL) (151.48.70.219) Using R 2.6.0 and 2.6.0 patched Italian version on Windows Vista systems, when selecting File-Choose directory, the sub-command Choose a folder doesn't go, being stopped to Desktop option. __ R-devel@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] no visible binding
Just to pick on this: 'how to react?'. Codetools does have false positives, and non-standard evaluation often triggers them. I've seen this one several times and pretty clearly a chararcter string is better style. But some are just false positives, including those in MASS. On Fri, 12 Oct 2007, Uwe Ligges wrote: Roger Bivand wrote: On Fri, 12 Oct 2007, roger koenker wrote: Could someone advise me about how to react to the message: * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) which becomes: as.character(substitute(response)) [1] response inside model.extract. I'm not sure why codetools doesn't pick up weights in the same context one line earlier, probably because weights is also assigned to. Yes. That object exists, but response does not. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] no visible binding
Roger Bivand wrote: On Fri, 12 Oct 2007, roger koenker wrote: Could someone advise me about how to react to the message: * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) which becomes: as.character(substitute(response)) [1] response inside model.extract. I'm not sure why codetools doesn't pick up weights in the same context one line earlier, probably because weights is also assigned to. Yes. That object exists, but response does not. Uwe Hope this helps, Roger X - as.matrix.csr(model.matrix(Terms, m, contrasts)) fit - { if (length(weights)) slm.wfit(X, Y, weights, method, ...) else slm.fit(X, Y, method, ...) } fit$terms - Terms fit$call - call attr(fit, na.message) - attr(m, na.message) class(fit) - c(if (is.matrix(Y)) mslm, slm) fit } url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ 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] no visible binding
On Fri, 12 Oct 2007, roger koenker wrote: Could someone advise me about how to react to the message: * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) which becomes: as.character(substitute(response)) [1] response inside model.extract. I'm not sure why codetools doesn't pick up weights in the same context one line earlier, probably because weights is also assigned to. Hope this helps, Roger X - as.matrix.csr(model.matrix(Terms, m, contrasts)) fit - { if (length(weights)) slm.wfit(X, Y, weights, method, ...) else slm.fit(X, Y, method, ...) } fit$terms - Terms fit$call - call attr(fit, na.message) - attr(m, na.message) class(fit) - c(if (is.matrix(Y)) mslm, slm) fit } url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] no visible binding
Could someone advise me about how to react to the message: * checking R code for possible problems ... NOTE slm: no visible binding for global variable 'response' from R CMD check SparseMwith * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749) The offending code looks like this: slm - function (formula, data, weights, na.action, method = csr, contrasts = NULL, ...) { call - match.call() m - match.call(expand.dots = FALSE) m$method - m$model - m$x - m$y - m$contrasts - m$... - NULL m[[1]] - as.name(model.frame) m - eval(m, sys.frame(sys.parent())) if (method == model.frame) return(m) Terms - attr(m, terms) weights - model.extract(m, weights) Y - model.extract(m, response) X - as.matrix.csr(model.matrix(Terms, m, contrasts)) fit - { if (length(weights)) slm.wfit(X, Y, weights, method, ...) else slm.fit(X, Y, method, ...) } fit$terms - Terms fit$call - call attr(fit, na.message) - attr(m, na.message) class(fit) - c(if (is.matrix(Y)) mslm, slm) fit } url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] File-Choose directory-Choose a folder (PR#9959)
Full_Name: Roberto Passera Version: 2.6.0 and 2.6.0 patched OS: Windows Vista Premium Submission from: (NULL) (151.48.70.219) Using R 2.6.0 and 2.6.0 patched Italian version on Windows Vista systems, when selecting File-Choose directory, the sub-command Choose a folder doesn't go, being stopped to Desktop option. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel