r-lib / backports Goto Github PK
View Code? Open in Web Editor NEWReimplementations of Functions Introduced Since R-3.0.0
Reimplementations of Functions Introduced Since R-3.0.0
Hello,
running tests/test_dotlibPaths.R
on R version 4.3.0
or greater fail with the following error:
.libPaths(save, include.site = length(.Library.site) && .Library.site %in% save)
Error in length(.Library.site) && .Library.site %in% save :
'length = 4' in coercion to 'logical(1)'
Best,
Charles Plessy (Debian Med packaging team)
In R < 3.6.0, removeSource()
only accepted functions. Starting in 3.6.0, it also accepted language objects.
A type
parameter was added to capture.output()
for R 3.2.1-patched which passes type
and split
down to the internal sink()
call. wch/r-source@d00b404.
It would be handy to add a backport so capture.output(type = "message")
could be used on e.g. R 3.1.
The extra_cols argument is fairly recent, the backport should emulate the behavior.
I feel like I'm missing something, but it seems like str2lang()
should be part of this list here:
Lines 64 to 76 in 45e4675
Am I missing something about how to depend on str2lang()
in versions prior to 3.6.0?
I'm not sure if this is actually consequential or how much control you have over it, but it looks like CRAN can't build the newer versions of backports
for r-release and r-oldrel for Windows, which is causing packages (e.g., mine, cobalt
) that import it to also fail to be built for those versions. I'm worried the CRAN team is going to come knocking at my door to tell me to fix these issues or they'll take my package down.
Can .libPaths
be added?
From https://stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html
.libPaths()
gets a new optioninclude.site
, allowing to not include the site library. (Thanks to Dario Strbenac's suggestion and Gabe Becker's PR#18016.)
Which looks like it was committed in svn r79677 (based on the bug report).
There is no backports 1.1.7 binary on CRAN for windows. It looks like there was an error in the CRAN build process: https://www.r-project.org/nosvn/R.check/r-release-windows-ix86+x86_64/backports-00check.html. Other than installing from source, is there another solution?
https://cloud.r-project.org/bin/windows/base/NEWS.R-4.4.0rc.html
L %||% R
newly in base is an expressive idiom for the phrasesif(!is.null(L)) L else R or if(is.null(L)) R else L
.
The functions str2lang()
and str2expression()
added in this commit are not yet in the README, under 3.6.0.
A new base::asplit
function was added in 3.6.0 which would bump up Depends: R (>=3.6.0)
.
The new function asplit() allow splitting an array or matrix by its margins.
It is defined as follows:
function (x, MARGIN)
{
dl <- length(dim(x))
if (!dl)
stop("dim(x) must have a positive length")
if (is.object(x))
x <- if (dl == 2L)
as.matrix(x)
else as.array(x)
d <- dim(x)
dn <- dimnames(x)
ds <- seq_len(dl)
if (is.character(MARGIN)) {
if (is.null(dnn <- names(dn)))
stop("'x' must have named dimnames")
MARGIN <- match(MARGIN, dnn)
if (anyNA(MARGIN))
stop("not all elements of 'MARGIN' are names of dimensions")
}
s.call <- ds[-MARGIN]
s.ans <- ds[MARGIN]
d.call <- d[-MARGIN]
d.ans <- d[MARGIN]
dn.call <- dn[-MARGIN]
dn.ans <- dn[MARGIN]
d2 <- prod(d.ans)
newx <- aperm(x, c(s.call, s.ans))
dim(newx) <- c(prod(d.call), d2)
ans <- vector("list", d2)
for (i in seq_len(d2)) {
ans[[i]] <- array(newx[, i], d.call, dn.call)
}
array(ans, d.ans, dn.ans)
}
The isNamespaceLoaded()
function was only introduced in R 3.2.0 (just checked because we want our package to support any R version since 3.0.0).
Per the documentation of ns-load
:
requireNamespace
is a wrapper forloadNamespace
analogous torequire
that returns a logical value.
loadedNamespaces
returns a character vector of the names of the loaded name spaces.
isNamespaceLoaded(pkg)
is equivalent to but more efficient thanpkg %in% loadedNamespaces()
.
So I think it's just:
isNamespaceLoaded <- function(pkg) {
pkg %in% loadedNamespaces()
}
I recently ran into this backwards compatibility problem.
sQuote()
and dQuote()
gained the explicit q
argument in R 3.6.0.
https://github.com/wch/r-source/blob/2c65d3d6bf25af0a3078639604feb280e69e1e46/doc/NEWS.Rd#L727-L729
sQuote()
anddQuote()
get an explicitq
argument with obvious default instead of usinggetOption("fancyQuotes")
implicitly and unconditionally.
from the release notes
CHANGES IN R 4.0.1
NEW FEATURES
- paste() and paste0() gain a new optional argument recycle0. When set to true, zero-length arguments are recycled leading to character(0) after the sep-concatenation, i.e., to the empty string "" if collapse is a string and to the zero-length value character(0) when collapse = NULL.
A package whose code uses this should depend on R (>= 4.0.1).
I have tried several ways to install the package but all fail in the same way with Error 127.
packageurl <- "https://cran.r-project.org/src/contrib/backports_1.1.8.tar.gz"
install.packages(packageurl, repos=NULL, dependencies=TRUE, verbose=TRUE, type="source")
trying URL 'https://cran.r-project.org/src/contrib/backports_1.1.8.tar.gz'
Content type 'application/x-gzip' length 18047 bytes (17 KB)
downloaded 17 KB
system (cmd0): C:/Users/APRMIL1/DOCUME1/R/R-40~1.2/bin/x64/R CMD INSTALL
*** arch - i386
"c:/rtools40/mingw32/bin/"gcc -I"C:/Users/APRMIL1/DOCUME1/R/R-40~1.2/include" -DNDEBUG -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c dotsElt.c -o dotsElt.o
c:/rtools40/mingw32/bin/gcc: not found
make: *** [dotsElt.o] Error 127
ERROR: compilation failed for package 'backports'
Argument extra_cols
was introduced in R-3.2.x.
The CRAN package page https://cran.r-project.org/package=backports has no instructions on how to use backports. A package developer will look for either a vignette or a README, but there's nothing.
Remove
Line 1 in 05e1381
so that the README.md file is bundled with the tarball, so that it ends up on CRAN.
Hi, I just tried to install gamlass into my miniconda library using conda and got the following error message. I don't understand what the problem is. I've installed many r packages without problem.
Please advise.
Thank you!
$ conda install --channel https://conda.anaconda.org/bioconda r-gamlss
Fetching package metadata ...........
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
Greetings -
I seem to have gotten tripped up trying to install the tidyverse package in R. The process stops at 'backports', which is a dependency of course that I am not familiar with. I have copied the output below. Any help in getting this to install is appreciated. I've used these packages before and never had any type of issue.
Thanks in advance!
Adam
IDE: RStudiov1.3.959
Rv4.0.2
The CI tests need pak
, but it is not found in R 3.3. Should those tests be removed (i.e. give up on R 3.3), or should the CI code be fixed?
Hi, windows builds on my CI server are unable to resolve a dependency on v1.1.9 of this package today - I get a 404 when trying to download binary version from cran:
Installing backports (1.1.9) ...
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/backports_1.1.9.zip'
Is this deliberate? I can't see a newer version on this cran, and this was working for me last week. I notice that some other cran repos do provide a 1.1.9 of this package (e.g.).
Since this is where CRAN wants packages to store files (if needed).
Hi, I am trying to install Bbplot (plotting with the format of the BBC plots) but run into an error related to Backports. I have tried to remove backports, remove the 00LOCK-backports, installing the binary version and using the install type=source command but keep on getting this message.
The master
branch of this repository will soon be renamed to main
, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.
That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master
--> main
change.
The purpose of this issue is to:
message id: euphoric_snowdog
e.g. in R 3.4.0 base::trimws
is defined as
function (x, which = c("both", "left", "right"))
{
which <- match.arg(which)
mysub <- function(re, x) sub(re, "", x, perl = TRUE)
if (which == "left")
return(mysub("^[ \t\r\n]+", x))
if (which == "right")
return(mysub("[ \t\r\n]+$", x))
mysub("[ \t\r\n]+$", mysub("^[ \t\r\n]+", x))
}
backports:::trimws
function (x, which = c("both", "left", "right"))
{
which = match.arg(which)
if (which %in% c("left", "both"))
x = gsub("^[[:space:]]", "", x)
if (which %in% c("right", "both"))
x = gsub("[[:space:]]$", "", x)
return(x)
}
While we could debate which implementation is better (I actually prefer the backports one), I don't think it is appropriate for this package to change the implementations unnecessarily.
A package using backports will change behavior if it is installed on a newer R that does define trimws.
base::trimws("a\v")
#> [1] "a\v"
backports:::trimws("a\v")
#> [1] "a"
I can install backports
from CRAN without any problems (except Rd warning), but when I try to load it I get following:
install.packages("backports")
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
Warning in install.packages("backports") :
'lib = "/usr/lib64/R/library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) y
trying URL 'https://cloud.r-project.org/src/contrib/backports_1.1.5.tar.gz'
Content type 'application/x-gzip' length 14798 bytes (14 KB)
==================================================
downloaded 14 KB
* installing *source* package ‘backports’ ...
** package ‘backports’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c dotsElt.c -o dotsElt.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c dotsLength.c -o dotsLength.o
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c init.c -o init.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o backports.so dotsElt.o dotsLength.o init.o -L/usr/lib64/R/lib -lR
installing to /home/jovetale/R/x86_64-redhat-linux-gnu-library/3.6/00LOCK-backports/00new/backports/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package ‘backports’
finding HTML links ... done
URLencode html
anyNA html
backports-package html
capture.output html
dir.exists html
dotsElt html
dotsLength html
endsWith html
file.info html
file.size html
get0 html
hasName html
import html
Rd warning: /tmp/RtmplnHXa3/R.INSTALLf1a2542f7681/backports/man/import.Rd:47: file link ‘.onLoad’ in package ‘base’ does not exist and so has been treated as a topic
isFALSE html
isTRUE html
lengths html
startsWith html
strrep html
trimws html
valid.factor html
warningCondition html
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (backports)
The downloaded source packages are in
‘/tmp/RtmpH7Ng8V/downloaded_packages’
library(backports)
Error in library(backports) : there is no package called ‘backports’
SessionInfo:
R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_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
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0
Tried both with latest version in CRAN and one earlier version, both have the same issue. Any idea what is going on?
See ?grDevices::palette
(below). These functions are 'base' R 4.* functions, but not part of the base
package. Should the backports
package also incorporate these?
View or manipulate the color palette which is used when col= has a numeric index and supporting functions.
palette(value)
palette.pals()
palette.colors(n = NULL, palette = "Okabe-Ito", alpha, recycle = FALSE)
...
Is available as of R 3.2.0 only.
TIL that !isTRUE(structure(TRUE, bla = "blub"))
on older versions of R: ropensci/tic#183 . Do we overwrite isTRUE()
in this case?
isTRUE(structure(TRUE, bla = "blub"))
#> [1] FALSE
Created on 2019-10-01 by the reprex package (v0.3.0)
sessionInfo()
#> R version 3.3.3 (2017-03-06)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 16.04.6 LTS
#>
#> locale:
#> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
#> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
#> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] magrittr_1.5 tools_3.3.3 htmltools_0.3.6 yaml_2.2.0
#> [5] Rcpp_1.0.2 stringi_1.4.3 rmarkdown_1.15 highr_0.8
#> [9] knitr_1.25 stringr_1.4.0 xfun_0.9 digest_0.6.21
#> [13] evaluate_0.14
I saw this package on my system today and it actually reminded me of some code I wrote a while ago. It looks like I wanted to implement something very similar to this previously.
https://github.com/Dasonk/future
I had backports for 2.14, 2.15 and 3.0 although I think the 3.0 was incomplete.
https://github.com/Dasonk/future2.14
https://github.com/Dasonk/future2.15
https://github.com/Dasonk/future3.0
Just a heads up that there will be another dots function ...names
in the next release.
I think you can copy the C function wholesale from the patch I submitted there.
Was released in R 3.6.0 (https://stat.ethz.ch/pipermail/r-announce/2019/000641.html). And of particular relevance for vignette building seems now to fail for R < 3.6 in R CMD check because this function is not available: https://travis-ci.org/github/r-lib/styler/builds/693410966 and https://travis-ci.org/github/r-lib/styler/jobs/693410971#L1186
Hello. I import backports
in my R package cobalt
(CRAN link). I require the latest version (1.1.7). However, I've had several users complain that they see the error
Error in deparse1(substitute(x)) : could not find function "deparse1"
I have the following line in my package code:
.onLoad <- function(libname, pkgname) {
backports::import(pkgname)
}
I feel that when users install cobalt
, backports
isn't being installed or updated to the latest version. I've told my users to manually install backports
or update their version of R. Do you know what's going on? Thanks.
Which is not ideal if somebody has multiple R versions and leads to hard to debug problems.
If backports
could export the functions at load time somehow, that would be great.
I have this
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS
lengths is already included, now backports shadows it
Here's the error message
install.packages("backports")
There is a binary version available but the source version is later:
binary source needs_compilation
backports 1.1.7 1.1.8 TRUEDo you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘backports’trying URL 'https://cran.rstudio.com/src/contrib/backports_1.1.8.tar.gz'
Content type 'application/x-gzip' length 18047 bytes (17 KB)downloaded 17 KB
- installing source package ‘backports’ ...
** package ‘backports’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/gfortran//bin/gcc -fopenmp -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/gfortran//include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dotsElt.c -o dotsElt.o
In file included from /Library/Frameworks/R.framework/Resources/include/R.h:55,
from dotsElt.c:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:62:10: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
^~~~~~~~~~~~~
compilation terminated.
make: *** [dotsElt.o] Error 1
ERROR: compilation failed for package ‘backports’- removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/backports’
- restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/backports’
Warning in install.packages :
installation of package ‘backports’ had non-zero exit status
Sorry to bother. I am running R 4.0.0 with no other packages installed. I tried to install devtools
but I received the error below. Any idea what the below error means?
install.packages("backports")
installing the source package ‘backports’
trying URL 'https://cloud.r-project.org/src/contrib/backports_1.1.7.tar.gz'
Content type 'application/x-gzip' length 17676 bytes (17 KB)
downloaded 17 KB
*** arch - i386
"c:/rtools40/mingw32/bin/"gcc -I"C:/PROGRA1/R/R-401.0/include" -DNDEBUG -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c dotsElt.c -o dotsElt.o
sh: c:/rtools40/mingw32/bin/gcc: No such file or directory
make: *** [C:/PROGRA1/R/R-401.0/etc/i386/Makeconf:222: dotsElt.o] Error 127
ERROR: compilation failed for package 'backports'
The downloaded source packages are in
‘C:\Users\X\AppData\Local\Temp\RtmpcHvAt5\downloaded_packages’
Warning message:
In install.packages("backports") :
installation of package ‘backports’ had non-zero exit status
Dear developers, I was working on a bug in one of my packages and I noticed a small inconsistency in the ...names()
function implemented in backports
vs the function included in R v4.2.1.
For example:
test1 <- function(...) {
...names()
}
test1("ABC")
#> [1] NA
while
bp_...names = getFromNamespace("...names", "backports")
test2 <- function(...) {
bp_...names()
}
test2("ABC")
#> NULL
Created on 2022-02-06 by the reprex package (v2.0.1)
Hi,
Thanks so much for your work on this package. Its a really great idea!
Don't know if its possible, but I'd love to use the native pipe |>
(introduced in R 4.1) in my packages without forcing everyone on less recent version to update.
Is this possible / in scope for backports
If not, do you have any ideas for alternative solutions?
only available for R >= 3.3.0, with caveats:
method = "shell"
method = "radix"
was available for sort()
under certain conditions in R < 3.3.0R_user_dir <-
function(package, which = c("data", "config", "cache"))
{
stopifnot(is.character(package), length(package) == 1L)
which <- match.arg(which)
home <- normalizePath("~")
path <-
switch(which,
data = {
if(nzchar(p <- Sys.getenv("R_USER_DATA_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_DATA_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("APPDATA"), "R", "data")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Application Support",
"org.R-project.R")
else
file.path(home, ".local", "share")
},
config = {
if(nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_CONFIG_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("APPDATA"), "R", "config")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Preferences",
"org.R-project.R")
else
file.path(home, ".config")
},
cache = {
if(nzchar(p <- Sys.getenv("R_USER_CACHE_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_CACHE_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Caches",
"org.R-project.R")
else
file.path(home, ".cache")
})
file.path(path, "R", package)
}
deparse1
(from R 4.0.0) is basically a simple wrapper of paste(deparse(...), collapse = ' ')
, the benefit being the output is guaranteed length-1.
This is a bit more tedious to handle the S3 stuff properly. PR would be welcome.
Hi,
I wanted to point out that .traceback()
was introduced in R 3.3.0 (April 2016) and could be added to backports. From the release notes:
New function .traceback() returns the stack trace which traceback() prints.
Best,
Florent
We are currently developing an application using R language and in that application, we use OSS libraries under GPLv3 (e.g. Matrix, tidyselect).
During the development, we noticed that some of OSS libraries depends on backports.
Is it possible to apply GPLv3 to our application?
I found that rprojroot which imports backports is published under GPLv3.
But not the earlier ones....
Incompatible with R-3.0.x.
It came to my attention that backports
does not export all functions from previous R releases, including str2expression
(and the related str2lang
). If this was deliberate, is there a reason for it? Thanks.
Introduced in 3.6.
Missed this because it is not mentioned in the NEWS.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.