Comments (4)
This is not a callr
issue. It is an S3 method lookup issue. E.g. this fails the same way:
f <- function(n) {
point <- function(x, y) {
stopifnot(is.numeric(x), is.numeric(y))
structure(list(x = x, y = y), class = "point")
}
abs.point <- function(x) {
sqrt(x$x ^ 2 + x$y ^ 2)
}
points <- mapply(point, runif(n), runif(n), SIMPLIFY = FALSE)
sapply(points, abs)
}
f(10)
#> Error in FUN(X[[i]], ...) : non-numeric argument to mathematical function
I think it is a bug in base R, but R-core devs might not share this opinion. One workaround is to put the S3 method definition into .GlobalEnv
(i.e. outside of a function in the Rmd for you).
from callr.
Thanks for the quick feedback.
Sorry to insist. Do you also not consider this a bug in my original scenario? There I did not have my s3 method definition wrapped in a function. My knitr code chunk is something like
point <- function(x, y) {
stopifnot(is.numeric(x), is.numeric(y))
structure(list(x = x, y = y), class = "point")
}
abs.point <- function(x) {
sqrt(x$x ^ 2 + x$y ^ 2)
}
points <- mapply(point, runif(5), runif(5), SIMPLIFY = FALSE)
sapply(points, abs)
When I create my .md
using rmarkdown::render
, all is fine. However pkgdown wraps render
with r_safe
, which causes the markdown generation to fail. If you agree that something seems off, I will open an issue at pkgdown.
from callr.
rmarkdown::render
evaluates code in an empty environment by default and this messes up the S3 lookup as well. You can set its envir
argument to .GlobalEnv
to work around this. This is done here: https://github.com/r-lib/pkgdown/blob/d4e9509f99265a551f03ef2696d2f0393f24103c/R/build-articles.R#L114-L123
But it is not done here:
https://github.com/r-lib/pkgdown/blob/c8726f9242b2b67f572c16422c83cdc8160c7628/R/build-home.R#L72-L79
So maybe the latter is biting you, and then yes, this needs a fix in pkgbuild
.
from callr.
Thanks for getting back to me.
from callr.
Related Issues (20)
- r_bg process stop after some time as session reload or closed HOT 9
- Subscript out of bounds error HOT 2
- system2("Rscript", args ="-e 1") via r_session$new(): Fatal error: creating temporary file for '-e' failed HOT 6
- Incompatible with websocket library HOT 1
- Release callr 3.7.3
- BATCH: outfile cannot have relative path with ~, while R CMD BATCH allows it? HOT 1
- rsession `get_running_time()` method HOT 1
- Feature request: Capture all R Console output with timestamp? HOT 6
- ignoring sigpipe signal HOT 2
- Wrong context for error handling? HOT 1
- Support `carrier::crate()` functions
- Set device for printing HOT 3
- Client library occasionally not found HOT 7
- Overwritten S3 methods when pak is loaded before callr
- Use library path of a fresh R session HOT 2
- Access original error HOT 2
- How do I pass object back to main session from `r_bg`. HOT 2
- Subprocess isolation HOT 6
- Reset non-set environment variables HOT 9
- How Do I Pass A Custom Function To callr::r()? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from callr.