Re: [Rd] predictions in nlme without fixed covariantes
This should be fixed in nlme 3.1-112. However, nlme has little support for formulae such as resp ~ 0, and does things like p:1 where p is the number of columns in the model matrix. 3.1-112 does better but evidently the design did not consider this possibility. On 30/09/2013 13:42, ONKELINX, Thierry wrote: Dear all, predict.lme() throws an error when the fixed part consists of only an intercept and using newdata. See the reproducible example below. I've tracked the error down to asOneFormula() which returns in this case NULL instead of a formula. Changing NULL instead of ~1 in that function (see below) solves the problem in the case of an intercept only model (m1). It does not solve the problem in case of a model without intercept nor covariates (m2). The package with altered asOneFormula() passes R CMD check on my machine. Best regards, Thierry Onkelinx library(nlme) data(Orthodont) m0 <- lme(distance ~ Sex, random = ~1|Subject, data = Orthodont) m1 <- lme(distance ~ 1, random = ~1|Subject, data = Orthodont) m2 <- lme(distance ~ 0, random = ~1|Subject, data = Orthodont) test.data <- Orthodont test.data$Fitted <- predict(m0, level = 0) test.data$Fitted.Newdata <- predict(m0, level = 0, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) test.data$Fitted <- predict(m0, level = 1) test.data$Fitted.Newdata <- predict(m0, level = 1, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) test.data$Fitted <- predict(m1, level = 0) test.data$Fitted.Newdata <- predict(m1, level = 0, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) test.data$Fitted <- predict(m1, level = 1) test.data$Fitted.Newdata <- predict(m1, level = 1, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) test.data$Fitted <- predict(m2, level = 0) test.data$Fitted.Newdata <- predict(m2, level = 0, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) test.data$Fitted <- predict(m2, level = 1) test.data$Fitted.Newdata <- predict(m2, level = 1, newdata = test.data) sum(abs(test.data$Fitted - test.data$Fitted.Newdata)) #new version asOneFormula <- ## Constructs a linear formula with all the variables used in a ## list of formulas, except for the names in omit function(..., omit = c(".", "pi")) { names <- unique(allVarsRec((list(... names <- names[is.na(match(names, omit))] if (length(names)) { eval(parse(text = paste("~", paste(names, collapse = "+")))[[1]]) } else { ~ 1 #this was NULL } } sessionInfo() R Under development (unstable) (2013-08-24 r63687) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Dutch_Belgium.1252 LC_CTYPE=Dutch_Belgium.1252 [3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C [5] LC_TIME=Dutch_Belgium.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] grid_3.1.0 lattice_0.20-15 tools_3.1.0 * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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
Re: [Rd] version comparison puzzle
It's an underflow problem. When comparing versions, "a.b.c" is converted first to the integer vector c(a,b,c) and then to the double precision value a + b/base + c/base^2 where base is 1 greater than the largest integer component of any of the versions: i.e 99912 in this case. The last term is then smaller than the machine precision so you can't tell the difference between 1.0.4 and 1.0.5. Martyn On Wed, 2013-10-02 at 23:41 -0400, Ben Bolker wrote: > Can anyone explain what I'm missing here? > > max(pp1 <- package_version(c("0.9911.3","1.0.4","1.0.5"))) > ## [1] ‘1.0.4’ > > max(pp2 <- package_version(c("1.0.3","1.0.4","1.0.5"))) > ## [1] ‘1.0.5’ > > I've looked at ?package_version , to no avail. > > Since max() goes to .Primitive("max") > I'm having trouble figuring out where it goes from there: > I **think** this is related to ?xtfrm , which goes to > .encode_numeric_version, which is doing something I really > don't understand (it's in base/R/version.R ...) > > .encode_numeric_version(pp1) > ## [1] 1 1 1 > ## attr(,"base") > ## [1] 9912 > ## attr(,"lens") > ## [1] 3 3 3 > ## attr(,".classes") > ## [1] "package_version" "numeric_version" > > .encode_numeric_version(pp2) > ## [1] 1.08 1.11 1.138889 > ## attr(,"base") > ## [1] 6 > ## attr(,"lens") > ## [1] 3 3 3 > ## attr(,".classes") > ## [1] "package_version" "numeric_version" > > sessionInfo() > R Under development (unstable) (2013-09-09 r63889) > Platform: i686-pc-linux-gnu (32-bit) > > [snip] > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] compiler_3.1.0 tools_3.1.0 > > __ > 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] version comparison puzzle
Actually, Bob O'Hara had a blog post about this in August 2012: http://occamstypewriter.org/boboh/2012/08/17/lme4_destined_to_become_stable_through_rounding/ The concluding chapter reads: "I have been worried that lme4 will never become stable, but this latest version mollifies me with the thought that the developers can’t go on forever, so eventually lme4 will become stable when the machine precision forces it to be rounded up to 1.0" Cheers, Jari Oksanen From: r-devel-boun...@r-project.org [r-devel-boun...@r-project.org] on behalf of Martyn Plummer [plumm...@iarc.fr] Sent: 03 October 2013 11:15 To: Ben Bolker Cc: r-de...@stat.math.ethz.ch Subject: Re: [Rd] version comparison puzzle It's an underflow problem. When comparing versions, "a.b.c" is converted first to the integer vector c(a,b,c) and then to the double precision value a + b/base + c/base^2 where base is 1 greater than the largest integer component of any of the versions: i.e 99912 in this case. The last term is then smaller than the machine precision so you can't tell the difference between 1.0.4 and 1.0.5. Martyn On Wed, 2013-10-02 at 23:41 -0400, Ben Bolker wrote: > Can anyone explain what I'm missing here? > > max(pp1 <- package_version(c("0.9911.3","1.0.4","1.0.5"))) > ## [1] ‘1.0.4’ > > max(pp2 <- package_version(c("1.0.3","1.0.4","1.0.5"))) > ## [1] ‘1.0.5’ > > I've looked at ?package_version , to no avail. > > Since max() goes to .Primitive("max") > I'm having trouble figuring out where it goes from there: > I **think** this is related to ?xtfrm , which goes to > .encode_numeric_version, which is doing something I really > don't understand (it's in base/R/version.R ...) > > .encode_numeric_version(pp1) > ## [1] 1 1 1 > ## attr(,"base") > ## [1] 9912 > ## attr(,"lens") > ## [1] 3 3 3 > ## attr(,".classes") > ## [1] "package_version" "numeric_version" > > .encode_numeric_version(pp2) > ## [1] 1.08 1.11 1.138889 > ## attr(,"base") > ## [1] 6 > ## attr(,"lens") > ## [1] 3 3 3 > ## attr(,".classes") > ## [1] "package_version" "numeric_version" > > sessionInfo() > R Under development (unstable) (2013-09-09 r63889) > Platform: i686-pc-linux-gnu (32-bit) > > [snip] > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] compiler_3.1.0 tools_3.1.0 > > __ > 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] check warning with .onLoad() and setClass()
Hi I am writing a package in which I define a new class in the .onLoad() hook: , | .onLoad <- function(libname, pkgname) { | setClass( | "inDrak", | representation( | init = "SpatialGridDataFrame" | ), | contains = "simObj" | ) | } ` The class "simObj" is defined in the package, which is in the depends section in the DESCRIPTION file: , | Package: InDrak | Type: Package | Title: Alien spread management simulation model for the Drakensberg | Version: 0.1-0 | Date: 2013-10-03_11-55 | Author: Rainer M. Krug | Maintainer: Rainer M Krug | Description: Simulate the spread of three Invasive Alien Plants under different | management and budget scenarios | License: GPL-3 | LazyLoad: yes | Depends: | RSQLite, | simecol | Imports: | methods, | sp, | spgrass6, | DBI, | logger, | fireSim, | seedProd, | seedGerm, | seedDisp | LinkingTo: Rcpp | Collate: | 'beginYear.R' | 'clearAliens.R' | 'competition.R' | 'cumulativeDc.R' | 'dcToIndLayer.R' | 'dispProb2D.R' | 'endYear.R' | 'fireAliens.R' | 'germEst.R' | 'initfunc.R' | 'layerIO.R' | 'layerNames.R' | 'main.R' | 'newInDrak.R' | 'onLoad.R' | 'package.R' | 'parameter.R' | 'parmsAcacia.R' | 'parmsBudget.R' | 'parmsFire.R' | 'parmsPinus.R' | 'parmsRubus.R' | 'resetOptions.R' | 'seedDispersal.R' | 'seedProduction.R' | 'stats.R' ` If important, the NAMESPACE file is here: , | export(depRateName) | export(exportRaster) | export(fireLayerName) | export(ignitionRiskName) | export(importAliens) | export(importClearingHistory) | export(importFireHistory) | export(importIgnitionRisk) | export(importSpecies) | export(importVegetation) | export(layerExists) | export(layerName) | export(newInDrak) | export(parameter) | export(parmsAcacia) | export(parmsBudget) | export(parmsFire) | export(parmsPinus) | export(parmsRubus) | export(resetOptions) | export(statDistName) | export(suitName) | import(DBI) | import(fireSim) | import(logger) | import(methods) | import(seedDisp) | import(seedGerm) | import(seedProd) | import(sp) | import(spgrass6) ` The package builds fine, it installs without problems and works as expected, but when checking it, I get the following error: , | $ R CMD check ./InDrak_0.1-0.tar.gz | * using log directory ‘/Users/rainerkrug/Documents/Projects/R-Packages/inDrak/InDrak.Rcheck’ | * using R version 3.0.1 (2013-05-16) | * using platform: x86_64-apple-darwin10.8.0 (64-bit) | * using session charset: UTF-8 | * checking for file ‘InDrak/DESCRIPTION’ ... OK | * checking extension type ... Package | * this is package ‘InDrak’ version ‘0.1-0’ | * checking package namespace information ... OK | * checking package dependencies ... OK | * checking if this is a source package ... OK | * checking if there is a namespace ... OK | * checking for executable files ... OK | * checking for hidden files and directories ... OK | * checking for portable file names ... OK | * checking for sufficient/correct file permissions ... OK | * checking whether package ‘InDrak’ can be installed ... OK | * checking installed package size ... OK | * checking package directory ... OK | * checking DESCRIPTION meta-information ... OK | * checking top-level files ... OK | * checking for left-over files ... OK | * checking index information ... OK | * checking package subdirectories ... OK | * checking R files for non-ASCII characters ... OK | * checking R files for syntax errors ... OK | * checking whether the package can be loaded ... OK | * checking whether the package can be loaded with stated dependencies ... OK | * checking whether the package can be unloaded cleanly ... OK | * checking whether the namespace can be loaded with stated dependencies ... WARNING | Error: .onLoad failed in loadNamespace() for ‘InDrak’, details: | call: reconcilePropertiesAndPrototype(name, slots, prototype, superClasses, | error: no definition was found for superclass “simObj” in the specification of class “inDrak” | Execution halted | | A namespace must be able to be loaded with just the base namespace | loaded: otherwise if the namespace gets loaded by a saved object, the | session will be unable to start. | | Probably some imports need to be declared in the NAMESPACE file. | * checking whether the namespace can be unloaded cleanly ... WARNING | Error: .onLoad failed in loadNamespace() for ‘InDrak’, details: | call: reconcilePropertiesAndPrototype(name, slots, prototype, superClasses, | error: no definition was found for superclass “simObj” in the specification of class “inDrak” | Execution halted | * checking loading without being on the library search path ... OK | * checking for unstated dependencies in R code ... OK | * checking S3 generic/method consistency ... OK | * checking replacement functions ... OK | * checking foreign function calls ... OK | * chec
Re: [Rd] check warning with .onLoad() and setClass()
Don't use .onLoad() to set class (or other nontrivial) information at load time. Use setLoadActions(), which was created exactly to get around the limitations of .onLoad(). For an example, see the Rcpp package, which uses this to set up load-time C++ linkages. John Chambers On Oct 3, 2013, at 3:22 AM, Rainer M Krug wrote: > Hi > > I am writing a package in which I define a new class in the .onLoad() > hook: > > , > | .onLoad <- function(libname, pkgname) { > | setClass( > | "inDrak", > | representation( > | init = "SpatialGridDataFrame" > | ), > | contains = "simObj" > | ) > | } > ` > > The class "simObj" is defined in the package, which is in the depends > section in the DESCRIPTION file: > > , > | Package: InDrak > | Type: Package > | Title: Alien spread management simulation model for the Drakensberg > | Version: 0.1-0 > | Date: 2013-10-03_11-55 > | Author: Rainer M. Krug > | Maintainer: Rainer M Krug > | Description: Simulate the spread of three Invasive Alien Plants under > different > | management and budget scenarios > | License: GPL-3 > | LazyLoad: yes > | Depends: > | RSQLite, > | simecol > | Imports: > | methods, > | sp, > | spgrass6, > | DBI, > | logger, > | fireSim, > | seedProd, > | seedGerm, > | seedDisp > | LinkingTo: Rcpp > | Collate: > | 'beginYear.R' > | 'clearAliens.R' > | 'competition.R' > | 'cumulativeDc.R' > | 'dcToIndLayer.R' > | 'dispProb2D.R' > | 'endYear.R' > | 'fireAliens.R' > | 'germEst.R' > | 'initfunc.R' > | 'layerIO.R' > | 'layerNames.R' > | 'main.R' > | 'newInDrak.R' > | 'onLoad.R' > | 'package.R' > | 'parameter.R' > | 'parmsAcacia.R' > | 'parmsBudget.R' > | 'parmsFire.R' > | 'parmsPinus.R' > | 'parmsRubus.R' > | 'resetOptions.R' > | 'seedDispersal.R' > | 'seedProduction.R' > | 'stats.R' > ` > > If important, the NAMESPACE file is here: > > , > | export(depRateName) > | export(exportRaster) > | export(fireLayerName) > | export(ignitionRiskName) > | export(importAliens) > | export(importClearingHistory) > | export(importFireHistory) > | export(importIgnitionRisk) > | export(importSpecies) > | export(importVegetation) > | export(layerExists) > | export(layerName) > | export(newInDrak) > | export(parameter) > | export(parmsAcacia) > | export(parmsBudget) > | export(parmsFire) > | export(parmsPinus) > | export(parmsRubus) > | export(resetOptions) > | export(statDistName) > | export(suitName) > | import(DBI) > | import(fireSim) > | import(logger) > | import(methods) > | import(seedDisp) > | import(seedGerm) > | import(seedProd) > | import(sp) > | import(spgrass6) > ` > > The package builds fine, it installs without problems and works as > expected, but when checking it, I get the following error: > > , > | $ R CMD check ./InDrak_0.1-0.tar.gz > | * using log directory > ‘/Users/rainerkrug/Documents/Projects/R-Packages/inDrak/InDrak.Rcheck’ > | * using R version 3.0.1 (2013-05-16) > | * using platform: x86_64-apple-darwin10.8.0 (64-bit) > | * using session charset: UTF-8 > | * checking for file ‘InDrak/DESCRIPTION’ ... OK > | * checking extension type ... Package > | * this is package ‘InDrak’ version ‘0.1-0’ > | * checking package namespace information ... OK > | * checking package dependencies ... OK > | * checking if this is a source package ... OK > | * checking if there is a namespace ... OK > | * checking for executable files ... OK > | * checking for hidden files and directories ... OK > | * checking for portable file names ... OK > | * checking for sufficient/correct file permissions ... OK > | * checking whether package ‘InDrak’ can be installed ... OK > | * checking installed package size ... OK > | * checking package directory ... OK > | * checking DESCRIPTION meta-information ... OK > | * checking top-level files ... OK > | * checking for left-over files ... OK > | * checking index information ... OK > | * checking package subdirectories ... OK > | * checking R files for non-ASCII characters ... OK > | * checking R files for syntax errors ... OK > | * checking whether the package can be loaded ... OK > | * checking whether the package can be loaded with stated dependencies ... OK > | * checking whether the package can be unloaded cleanly ... OK > | * checking whether the namespace can be loaded with stated dependencies ... > WARNING > | Error: .onLoad failed in loadNamespace() for ‘InDrak’, details: > | call: reconcilePropertiesAndPrototype(name, slots, prototype, > superClasses, > | error: no definition was found for superclass “simObj” in the > specification of class “inDrak” > | Execution halted > | > | A namespace must be able to be loaded with just the base namespace > | loaded: otherwise if the namespace gets loaded by a saved object, the > | session will be unable to start. > | > | Probably some i
[Rd] Including R code from another package...
R-developers: I had a quick question for the group -- let's say a package I am developing depends on a single, small function from a large CRAN-listed package. I can, of course, set a dependency within my own package, but are there means by which I can include the R script + man file DIRECTLY in my package (of course attributing the code to the original programmer). Does it require me asking the package manager directly? If not, what is the proper way to cite that a given script was coded by someone else? Cheers! --j -- Jonathan A. Greenberg, PhD Assistant Professor Global Environmental Analysis and Remote Sensing (GEARS) Laboratory Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 259 Computing Applications Building, MC-150 605 East Springfield Avenue Champaign, IL 61820-6371 Phone: 217-300-1924 http://www.geog.illinois.edu/~jgrn/ AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Including R code from another package...
If the package is on CRAN then the license should be a free one that would let you copy whatever you want from it. However it would be most polite to contact the original author first. I know that I have given permission for a couple of my functions to be included in other packages where it would clearly be overkill for the other package to depend on my package for just the one function. Since the authors of those packages asked me first I make sure to send them any updates that I make to those functions so that they can keep the copy in their package current with mine if they want to. If you do not receive a reply from the author of the original function then check the license, you can probably still include the function and documentation in your package, just be sure to give proper credit and make sure that your license is compatible. On Thu, Oct 3, 2013 at 1:27 PM, Jonathan Greenberg wrote: > R-developers: > > I had a quick question for the group -- let's say a package I am > developing depends on a single, small function from a large > CRAN-listed package. I can, of course, set a dependency within my own > package, but are there means by which I can include the R script + man > file DIRECTLY in my package (of course attributing the code to the > original programmer). Does it require me asking the package manager > directly? If not, what is the proper way to cite that a given script > was coded by someone else? Cheers! > > --j > > -- > Jonathan A. Greenberg, PhD > Assistant Professor > Global Environmental Analysis and Remote Sensing (GEARS) Laboratory > Department of Geography and Geographic Information Science > University of Illinois at Urbana-Champaign > 259 Computing Applications Building, MC-150 > 605 East Springfield Avenue > Champaign, IL 61820-6371 > Phone: 217-300-1924 > http://www.geog.illinois.edu/~jgrn/ > AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Including R code from another package...
On 03.10.2013 21:39, Greg Snow wrote: If the package is on CRAN then the license should be a free one that would let you copy whatever you want from it. That is not true for all CRAN packages. However it would be most polite to contact the original author first. I know that I have given permission for a couple of my functions to be included in other packages where it would clearly be overkill for the other package to depend on my package for just the one function. Since the authors of those packages asked me first I make sure to send them any updates that I make to those functions so that they can keep the copy in their package current with mine if they want to. If you do not receive a reply from the author of the original function then check the license, you can probably still include the function and documentation in your package, just be sure to give proper credit and make sure that your license is compatible. Indeed. Uwe Ligges On Thu, Oct 3, 2013 at 1:27 PM, Jonathan Greenberg wrote: R-developers: I had a quick question for the group -- let's say a package I am developing depends on a single, small function from a large CRAN-listed package. I can, of course, set a dependency within my own package, but are there means by which I can include the R script + man file DIRECTLY in my package (of course attributing the code to the original programmer). Does it require me asking the package manager directly? If not, what is the proper way to cite that a given script was coded by someone else? Cheers! --j -- Jonathan A. Greenberg, PhD Assistant Professor Global Environmental Analysis and Remote Sensing (GEARS) Laboratory Department of Geography and Geographic Information Science University of Illinois at Urbana-Champaign 259 Computing Applications Building, MC-150 605 East Springfield Avenue Champaign, IL 61820-6371 Phone: 217-300-1924 http://www.geog.illinois.edu/~jgrn/ AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 __ 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] R-3.0.2 - Win7_64 - alone_decoder.c: Permission denied error
On 30.09.2013 19:47, Adler, Avraham wrote: Hello. When trying to compile R-3.0.2 on Windows 7 64bit, I get an error relating to "alone_decoder.c: Permission denied." The entire error code is copied below. gcc -std=gnu99 -m64 -shared -o Riconv.dll Riconv.def win_iconv.o touch stamp gcc -std=gnu99 -m64 -I../../include -I. -Iapi -DLZMA_API_STATIC -DHAVE_CONFIG_H -DWIN32 -O3 -Wall -pedantic -march=core-avx-i -O3 --param l1-cache-line-size=64 --param l1-cache-size=32 --param l2-cache-size=256 -c alone_decoder.c -o alone_decoder.o cc1.exe: fatal error: alone_decoder.c: Permission denied compilation terminated. make[5]: *** [alone_decoder.o] Error 1 make[4]: *** [all] Error 2 make[3]: *** [rlibs] Error 1 make[2]: *** [../../bin/x64/R.dll] Error 2 make[1]: *** [rbuild] Error 2 make: *** [all] Error 2 However, I do *not* get this error when compiling R-patched as of 9/17/2013 using the exact same parameters on the same system. What does this error mean? Is it possible something changed between that version and the release which is causing this error? What may I do to correct the error? Well, there is a Windows binary for 3.0.2 on CRAN and we had no problems to build it. So probably the problem is on your end. Best, Uwe Ligges Thank you very much, Avraham Adler __ 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] [PATCH] file.access returns success for NA
Currently on R I get the following: > file.access(c("doesNotExist", NA)) doesNotExist -10 where 0 means success. Is the 0 correct? I was expecting either NA or -1. ?file.access does not mention how NA values should be handled. The subsection "3.3.4 NA handling" from the R Language Definition manual suggest to me that file.access should return NA if given NA. I interpret it in this way because if an element in the input vector is NA, that means that there is a filename that exists but is not known. Thus, I thought that file.access should return NA because it is not known whether the file corresponding to the missing filename exists. Perhaps file.access acts in this way to maintain compatibility with the S-PLUS function ‘access’ (which I currently do not have a way of testing to see how it handles NAs) ? If this is the case, would a patch for ?file.access be considered? Below is a patch that changes the return of an NA to NA. Index: trunk/src/main/platform.c === --- trunk/src/main/platform.c (revision 64011) +++ trunk/src/main/platform.c (working copy) @@ -1299,7 +1299,7 @@ access(R_ExpandFileName(translateChar(STRING_ELT(fn, i))), modemask); #endif - } else INTEGER(ans)[i] = FALSE; + } else INTEGER(ans)[i] = NA_INTEGER; UNPROTECT(1); return ans; } Comments? Scott > sessionInfo() R Under development (unstable) (2013-09-27 r64011) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base > -- Scott Kostyshak Economics PhD Candidate Princeton University __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel