Neal Richardson
2017-Sep-08 17:52 UTC
[Rd] Bug: dput/deparse with named character vector inside list
Hi, I noticed some R-devel failures on CRAN on a package I maintain: https://cloud.r-project.org/web/checks/check_results_httptest.html It appears that 'dput'/'deparse' is returning an invalid object when there is a named character vector inside a list. Here is a minimal example that reproduces the issue:> z <- list(a=c(b="foo")) > str(z)List of 1 $ a: Named chr "foo" ..- attr(*, "names")= chr "b"> dput(z)list(a = b = "foo")> parse(text=deparse(z))Error in parse(text = deparse(z)) : <text>:1:12: unexpected '=' 1: list(a = b ^ But it works fine if you just provide a named character vector:> dput(z$a)structure("foo", .Names = "b") I know that there were some recent improvements to 'deparse' (c73120, 73144). Among the failures on my package on R-devel on CRAN, a test run on version as old as r73150 does manifest this bug (https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/httptest-00check.html), so the timing does suggest that those changes could be related. Neal> sessionInfo()R Under development (unstable) (2017-09-07 r73219) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Sierra 10.12.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.5.0
Martin Maechler
2017-Sep-11 14:52 UTC
[Rd] Bug: dput/deparse with named character vector inside list
>>>>> Neal Richardson <neal.p.richardson at gmail.com> >>>>> on Fri, 8 Sep 2017 10:52:32 -0700 writes:> Hi, > I noticed some R-devel failures on CRAN on a package I maintain: > https://cloud.r-project.org/web/checks/check_results_httptest.html > It appears that 'dput'/'deparse' is returning an invalid object when > there is a named character vector inside a list. Here is a minimal > example that reproduces the issue: >> z <- list(a=c(b="foo")) >> str(z) > List of 1 > $ a: Named chr "foo" > ..- attr(*, "names")= chr "b" >> dput(z) > list(a = b = "foo") >> parse(text=deparse(z)) > Error in parse(text = deparse(z)) : <text>:1:12: unexpected '=' > 1: list(a = b > ^ > But it works fine if you just provide a named character vector: >> dput(z$a) > structure("foo", .Names = "b") ("of course", because that had been tested quite extensively). Thank you for reporting. It is clearly a bug. We're happy if your report it formally (https://bugs.r-project.org), but as it is only in "R-devel", the development version of R, to report here is indeed perfect. > I know that there were some recent improvements to 'deparse' (c73120, > 73144). Among the failures on my package on R-devel on CRAN, a test > run on version as old as r73150 does manifest this bug > (https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-fedora-gcc/httptest-00check.html), > so the timing does suggest that those changes could be related. I'm sure they are (and it is mea culpa). I will address this ASAP. Martin > Neal >> sessionInfo() > R Under development (unstable) (2017-09-07 r73219) > Platform: x86_64-apple-darwin15.6.0 (64-bit) > Running under: macOS Sierra 10.12.6 > Matrix products: default > BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib > LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib > locale: > [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 > attached base packages: > [1] stats graphics grDevices utils datasets methods base > loaded via a namespace (and not attached): > [1] compiler_3.5.0
Apparently Analagous Threads
- CRAN check fails if website is unavailable on Fedora platforms
- R-alpha: dump() / dput() -- fail for "environmental" and attributed functions
- as.data.frame(NULL) & as.data.frame(list()) & bug in dput(.)
- sourcing dput output
- dput/dget when a data frame has 2 rows (PR#9627)