[Rd] Depends, Suggests and .First.lib
Dear all, I am working in the development of a package with more or less 25 functions. Most of them do not have dependencies on other extra packages. However, I am including three GUIs for the most important functions of the package. These three GUIs need the gWidgets package. Moreover, there is another function which makes use of latticeExtra and latticedl. Since these three packages are not needed for successfully load my package I understand, following the guidelines of "Writing R Extensions", that they do not need to be included under "Depends" but under "Suggests". But I am including the GUIs as a help for those people who are reluctant to the use of a console, so I would prefer these dependencies to be loaded automatically. Therefore I have written a zzz.R with this .First.lib function: .First.lib <- function(lib, pkg){ require(vcd, quietly = TRUE) if (!require(lattice, quietly = TRUE)) warning('lattice package could not be loaded. Some funcionalities may not be available') if (!require(latticedl, quietly = TRUE)) warning('latticedl package could not be loaded. Some funcionalities may not be available') if (!require(latticeExtra, quietly = TRUE)) warning('latticeExtra package could not be loaded. Some funcionalities may not be available') if (!(require(gWidgets, quietly = TRUE) && (require(gWidgetstcltk, quietly = TRUE) || require(gWidgetsRGtk2, quietly = TRUE warning('gWidgets package or their associated packages could not be loaded. GUI funcionalities will not be available') } Perhaps it is better and easier to include these packages in "Depends" but I am not sure. I would appreciate your advice. Another question is about the load of data. I am including two datasets which are used by two functions. They are small (about 6kB). Is it better to use LazyData:no or insert a data() inside the code of these two functions? Thank you very much for your help. Best regards. Oscar Perpiñán Lamigueiro Dpto. de Ingeniería Eléctrica EUITI-UPM __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Possible bug in fisher.test() (PR#14196)
# is there a bug in the calculation of the odds ratio in fisher.test? # Nicholas Horton, nhor...@smith.edu Fri Jan 22 08:29:07 EST 2010 x1 = c(rep(0, 244), rep(1, 209)) x2 = c(rep(0, 177), rep(1, 67), rep(0, 169), rep(1, 40)) or1 = sum(x1==1&x2==1)*sum(x1==0&x2==0)/ (sum(x1==1&x2==0)*sum(x1==0&x2==1)) library(epitools) or2 = oddsratio.wald(x1, x2)$measure[2,1] or3 = fisher.test(x1, x2)$estimate # or1=or2 = 0.625276, but or3=0.6259267! I'm running R 2.10.1 under Mac OS X 10.6.2. Nick Nicholas Horton Department of Mathematics and Statistics, Smith College Clark Science Center, Northampton, MA 01063-0001 http://www.math.smith.edu/~nhorton __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Possible bug in fisher.test() (PR#14196)
On 27-Jan-10 17:30:10, nhor...@smith.edu wrote: ># is there a bug in the calculation of the odds ratio in fisher.test? ># Nicholas Horton, nhor...@smith.edu Fri Jan 22 08:29:07 EST 2010 > > x1 = c(rep(0, 244), rep(1, 209)) > x2 = c(rep(0, 177), rep(1, 67), rep(0, 169), rep(1, 40)) > > or1 = sum(x1==1&x2==1)*sum(x1==0&x2==0)/ > (sum(x1==1&x2==0)*sum(x1==0&x2==1)) > > library(epitools) > or2 = oddsratio.wald(x1, x2)$measure[2,1] > > or3 = fisher.test(x1, x2)$estimate > ># or1=or2 = 0.625276, but or3=0.6259267! > > I'm running R 2.10.1 under Mac OS X 10.6.2. > Nick Not so. Look closely at ?fisher.test: Value: [...] estimate: an estimate of the odds ratio. Note that the _conditional_ Maximum Likelihood Estimate (MLE) rather than the unconditional MLE (the sample odds ratio) is used. Only present in the 2 by 2 case. Your or1 (and presumably the epitools value also) is the sample OR. The conditional MLE is the value of rho (the OR) that maximises the probability of the table *conditional* on the margins. In this case it differs slightly from the sample OR (by 0.1%). For smaller tables it will tend to differ even more, e.g. M1 <- matrix(c(4,7,17,18),nrow=2) M1 # [,1] [,2] # [1,]4 17 # [2,]7 18 (4*18)/(17*7) # [1] 0.605042 fisher.test(M1)$estimate # odds ratio # 0.6116235 ## (1.1% larger than sample OR) M2 <- matrix(c(1,2,4,5),nrow=2) M2 # [,1] [,2] # [1,]14 # [2,]25 (1*5)/(4*2) # [1] 0.625 fisher.test(M2)$estimate # odds ratio # 0.649423 ## (3.9% larger than sample OR) The probability of a table matrix(c(a,b,c,d),nrow=2) given the marginals (a+b),(a+c),(b+c) and hence also (c+d) is a function of the odds ratio only. Again see ?fisher.test: "given all marginal totals fixed, the first element of the contingency table has a non-central hypergeometric distribution with non-centrality parameter given by the odds ratio (Fisher, 1935)." The value of the odds ratio which maximises this (for given observed 'a') is not the sample OR. Hoping this helps, Ted. E-Mail: (Ted Harding) Fax-to-email: +44 (0)870 094 0861 Date: 27-Jan-10 Time: 18:14:57 -- XFMail -- __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] poisson.test from stats package does not pass the conf.level (PR#14195)
m...@niaid.nih.gov wrote: Hi, The poisson.test function from stats package does not pass the conf.level p= arameter for the two-sample test. Here is an example: poisson.test(c(2,4),c(20,14),conf.level=3D.95)$conf.int poisson.test(c(2,4),c(20,14),conf.level=3D.9)$conf.int Here is the solution, change: RVAL <- binom.test(x, sum(x), r * T[1]/(r * T[1] + T[2]), alternative =3D alternative) to: RVAL <- binom.test(x, sum(x), r * T[1]/(r * T[1] + T[2]), alternative =3D alternative, conf.level=3Dconf.level) Now fixed in 2.10.1 patched and R-devel. Thanks. -- 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 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] poisson.test from stats package does not pass the conf.level (PR#14197)
m...@niaid.nih.gov wrote: > Hi, > > The poisson.test function from stats package does not pass the conf.level p= > arameter for the two-sample test. Here is an example: > > poisson.test(c(2,4),c(20,14),conf.level=3D.95)$conf.int > poisson.test(c(2,4),c(20,14),conf.level=3D.9)$conf.int > > > Here is the solution, change: > > RVAL <- binom.test(x, sum(x), r * T[1]/(r * T[1] + T[2]), > alternative =3D alternative) > > to: > > RVAL <- binom.test(x, sum(x), r * T[1]/(r * T[1] + T[2]), > alternative =3D alternative, conf.level=3Dconf.level) Now fixed in 2.10.1 patched and R-devel. Thanks. -- 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 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] "Too many raster images" in devPS.c
Hi Wolfgang Huber wrote: Hi, I am finding the recently added [1] functionality of embedding raster images into plots on R devices very useful! Thanks to Paul Murrell and others for providing that. I noted that in https://svn.r-project.org/R/trunk/src/library/grDevices/src/devPS.c a macro is defined: #define MAX_RASTERS 64, and consequently, I get Error in grid.Call.graphics("L_raster", x$raster, x$x, x$y, x$width, x$height, : Too many raster images even for relatively innocent graphics, such as extensions of [2] (which I made with Bioconductor's "splots" package). Besides that, I imagine that raster images could be useful as 'glyphs' in various types of plots. Besides the not so helpful option of patching that macro in my private copy of R, is there an intention to extend this functionality to accommodate for larger plots more generally? A simple solution (given the current implementation) would be to allow the user to specify the max number of raster images when starting a PDF file, e.g., ... pdf("plotwithlotsofimages.pdf", maxRaster=1024) Would that suffice? Paul [1] http://developer.r-project.org/Raster/raster-RFC.html [2] http://www.ebi.ac.uk/~huber/pub/Druggable_ratio_1_before.pdf Thank you and best wishes, Wolfgang -- Wolfgang Huber EMBL http://www.embl.de/research/units/genome_biology/huber/contact __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel