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)
- Posit rebranding
- Upkeep for callr (2023)
- Add alt-text to pictures, plots, etc; see https://posit.co/blog/knitr-fig-alt/ for examples
- Alternative to `arch` argument with `callr` v3.3.2 HOT 2
- r_bg processes hang when waiting for others to spawn HOT 2
- How to detect failure in `r_bg()` ? HOT 1
- Release callr 3.7.4
- please do not run unsigned dll files with random names from temp folder HOT 7
- Release callr 3.7.5
- callr update from CRAN HOT 1
- callr update from CRAN HOT 2
- Rtmp files left in /tmp directory with VSCode HOT 2
- How to use customize functions in the `func` function? HOT 4
- callr update from CRAN HOT 3
- Release callr 3.7.6 HOT 1
- how to get out of session$attach() HOT 5
- Setting different R_HOME for the callr subprocess HOT 1
- r_process subclass shouldn't be cloneable HOT 1
- Spawn background processes across HPC cluster nodes HOT 1
- Use `testthat::with_mock()` instead of mockery
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.