[Rd] A bug in file.copy(), deletes file contents
Hi, I've discovered a way to accidentally delete all your files with file.copy(). This involves copying a directory to itself by bypassing the check `if (recursive && to %in% from)` by pointing to a directory with two differing ways. Here I'm copying the directory foo to itself: dir.create("foo") cat(file = "foo/bar.txt", "baz\n") readLines("foo/bar.txt") #> [1] "baz" file.copy("foo", ".", recursive = TRUE) #> [1] TRUE readLines("foo/bar.txt") #> character(0) Since "foo" is not ".", the directory is copied to itself and the function calls file.create() to delete the file contents. A simple fix would be to use `if (recursive && (to %in% from || from %in% list.files(to)))` instead, I think. This could be slow if there are a lot of files, so maybe this could be faster: if (recursive && (to %in% from || normalizePath(dirname(normalizePath(from))) == normalizePath(to))) There I'm looking if the parent dir of `from` matches the dir of `to`. At least on my machine dirname() gives different path syntax than normalizePath() so both input and output of dirname() needs to be put though normalizePath(). There is a related bug in file.create(): it doesn't check if the file already exists and goes on to delete contents of existing files. Pasi Haapakorva __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R 3.6.0 is released
The build system rolled up R-3.6.0.tar.gz (codename "Planting of a Tree") this morning. The list below details the changes in this release. You can get the source code from http://cran.r-project.org/src/base/R-3/R-3.6.0.tar.gz or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course. For the R Core Team, Peter Dalgaard These are the checksums (md5 and SHA-256) for the freshly created files, in case you wish to check that they are uncorrupted: MD5 (AUTHORS) = b9c44f9f78cab3184ad9898bebc854b4 MD5 (COPYING) = eb723b61539feef013de476e68b5c50a MD5 (COPYING.LIB) = a6f89e2100d9b6cdffcea4f398e37343 MD5 (FAQ) = 28a3942a7129877e9af1d5ea16202052 MD5 (INSTALL) = 7893f754308ca31f1ccf62055090ad7b MD5 (NEWS) = 6d227865440cc1ece3d97bdf4a8ee41e MD5 (NEWS.0) = bfcd7c147251b5474d96848c6f57e5a8 MD5 (NEWS.1) = eb78c4d053ec9c32b815cf0c2ebea801 MD5 (NEWS.2) = 591dcf615162127f904e4e461f330ce9 MD5 (R-latest.tar.gz) = 65601eac6d353f7efb5b48c29097c2fb MD5 (README) = f468f281c919665e276a1b691decbbe6 MD5 (RESOURCES) = 529223fd3ffef95731d0a87353108435 MD5 (THANKS) = 08158353102084599797db8c9ccf8e2a MD5 (VERSION-INFO.dcf) = 97d5e3df5e5ac56750695e4b49145fae MD5 (R-3/R-3.6.0.tar.gz) = 65601eac6d353f7efb5b48c29097c2fb 2cde824a7b18958e5f06b391c801c8288be0f84fa8934b7ddefef23c67e60c09 AUTHORS e6d6a009505e345fe949e1310334fcb0747f28dae2856759de102ab66b722cb4 COPYING 6095e9ffa777dd22839f7801aa845b31c9ed07f3d6bf8a26dc5d2dec8ccc0ef3 COPYING.LIB 38219d9c6221ccfbf075ef03711b420a1aa8731f890c8f2337148b602a217c2d FAQ f87461be6cbaecc4dce44ac58e5bd52364b0491ccdadaf846cb9b452e9550f31 INSTALL 184dfa18e3069782d1092b289a6fe6ef85feb951cd4d1566b225c746d29a5420 NEWS 4e21b62f515b749f80997063fceab626d7258c7d650e81a662ba8e0640f12f62 NEWS.0 12b30c724117b1b2b11484673906a6dcd48a361f69fc420b36194f9218692d01 NEWS.1 ca04f78ffe54afa326fe3ed40e7e1411acaed2fa5ead97ddf51c6aa5b7bc NEWS.2 36fcac3e452666158e62459c6fc810adc247c7109ed71c5b6c3ad5fc2bf57509 R-latest.tar.gz 2fdd3e90f23f32692d4b3a0c0452f2c219a10882033d1774f8cadf25886c3ddc README 408737572ecc6e1135fdb2cf7a9dbb1a6cb27967c757f1771b8c39d1fd2f1ab9 RESOURCES 2d2e85e85574c4430951f6b070c08cd5aff1602abfd1bb162bed6d89c436b11f THANKS 05bd1202b132c8e91a8887d923fcc525cfb3bf81c67847d15876b88bf0c68a71 VERSION-INFO.dcf 36fcac3e452666158e62459c6fc810adc247c7109ed71c5b6c3ad5fc2bf57509 R-3/R-3.6.0.tar.gz This is the relevant part of the NEWS file CHANGES IN R 3.6.0: SIGNIFICANT USER-VISIBLE CHANGES: * Serialization format version 3 becomes the default for serialization and saving of the workspace (save(), serialize(), saveRDS(), compiler::cmpfile()). Serialized data in format 3 cannot be read by versions of R prior to version 3.5.0. Serialization format version 2 is still supported and can be selected by version = 2 in the save/serialization functions. The default can be changed back for the whole R session by setting environment variables R_DEFAULT_SAVE_VERSION and R_DEFAULT_SERIALIZE_VERSION to 2. For maximal back-compatibility, files vignette.rds and partial.rdb generated by R CMD build are in serialization format version 2, and resave by default produces files in serialization format version 2 (unless the original is already in format version 3). * The default method for generating from a discrete uniform distribution (used in sample(), for instance) has been changed. This addresses the fact, pointed out by Ottoboni and Stark, that the previous method made sample() noticeably non-uniform on large populations. See PR#17494 for a discussion. The previous method can be requested using RNGkind() or RNGversion() if necessary for reproduction of old results. Thanks to Duncan Murdoch for contributing the patch and Gabe Becker for further assistance. The output of RNGkind() has been changed to also return the 'kind' used by sample(). NEW FEATURES: * Sys.setFileTime() has been vectorized so arguments path and time of length greater than one are now supported. * axis() gets new option gap.axis = NA for specifying a multiplication factor for the minimal "gap" (distance) between axis labels drawn. Its default is 1 for labels _parallel_ to the axis, and 0.25 for perpendicular ones. Perpendicular labels no longer overlap, fixing bug PR#17384. * The default method of plot() gains new arguments xgap.axis = NA and ygap.axis = NA to be passed to the x- and y- axis(.., gap.axis=*) calls. * removeSource() now works not only for functions but also for some language objects. * as.call(), rep.int(), rep_len() and nchar() dispatch internally. * is(object, class2) looks for class2 in the calling namespace after looking in the namespace of class(object). * extendrange(.., f) with a length-2 f now extends separately to t
Re: [Rd] configure script issue with -flto with recent gcc and system ar/ranlib
On 4/25/19 6:11 PM, Thomas König wrote: Hi Tomas, On 4/23/19 2:59 PM, Thomas König wrote: Hi, there can be an issue with recent gcc where the system-installed "ar" and "ranlib" commands cannot handle LTO binaries. On compilation, this manifests itself with error messages claiming that they need extra plugins. Thanks for the report. What was the version of binutils on the system with this problem? On my Ubuntu 18.04 I can use the binutils version of "ar" and "ranlib" with --enable-lto without problems. I read that with recent binutils (2.25?), the LTO plugin should be loaded automatically, so one does not have to use the wrappers anymore. This was with, on x86_64-pc-linux-gnu, GNU ar (GNU Binutils; openSUSE Leap 42.3) 2.31.1.20180828-19 and, on powerpc64le-unknown-linux-gnu, GNU ar version 2.27-34.base.el7 both with a recent gcc 9.0.1 snapshot. Thanks. I can reproduce with Leap 42.3 and gcc-8, the binutils ar fails with errors "plugin needed to handle lto object". This is because "ar" cannot find the LTO plugin liblto_plugin.so. The plugin needs to be in directory /usr/lib/bfd-plugins for ar/nm/ranlib to find it. On 42.3, gcc installation fails to create that directory and link its plugin there. I read that the problem is fixed in Leap 45. To work this around in Leap 42.3, one may build R using the wrappers (AR=gcc-ar RANLIB=gcc-ranlib NM=gcc-nm) or create the link. mkdir /usr/lib/bfd-plugins ln -s /usr/lib64/gcc/x86_64-suse-linux/8/liblto_plugin.so /usr/lib/bfd-plugins Similar wrappers exist also for LLVM, but I read that LLVM installation on Leap 42.3 links its plugin properly from /usr/lib/bfd-plugins. Best Tomas Regards Thomas __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Error in glm(..., family=quasi(..., variance=list(...)))
In a glm() call using a quasi() family, one may define a custom variance function in the form of a "list containing components varfun, validmu, dev.resids, initialize and name" (quoting the help page for family). In trying to do so, I run into the following issue that I have not seen discussed previously: x <- runif(1000, min=0, max=1) y <- x + rnorm(1000, mean=0, sd=1)*x^(3/4) vf <- function(mu) { abs(mu)^(3/4) } vm <- function(mu) { rep(TRUE, length(mu)) } dr <- function(y, mu, wt) { (y-mu)^2 } it <- expression({ n <- rep.int(1, nobs); mustart <- y }) glm(y ~ x, family=quasi(link="identity", variance=list(varfun=vf, validmu=vm, dev.resids=dr, initialize=it, name="custom"))) This gives "Error in switch(vtemp, constant = { : EXPR must be a length 1 vector" from line 576 in file family.R (https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/library/stats/R/family.R#L576). I believe this is due to line 573 "vtemp <- substitute(variance)" and 574 "if (!is.character(vtemp)) vtemp <- deparse(vtemp)" where vtemp becomes a length 2 character vector because, by default, deparse() breaks lines at width.cutoff = 60L characters. In stepping through quasi() during debug, setting vtemp <- (vtemp, collapse=" ") on line 576 avoids the error. A workaround from https://tolstoy.newcastle.edu.au/R/help/05/06/6795.html appears to be to define one's own complete quasi2() function with the desired variance function pre-stored. Is this known/expected, or should I file a bug? Many thanks and best regards Daniel > sessionInfo() R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 14393) Matrix products: default locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.6.0 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel