When using data.table in an Rmd document and then trying to use purrr::map to apply the rmarkdown::render function the Rmd is nolonger data.table aware and rendering fails.
x <- "test.Rmd"
# Fails---
purrr::map(x, rmarkdown::render)
#Quitting from lines 13-23 (dattableconflict.Rmd)
#Error: `:=` can only be used within a quasiquoted argument
# Sucessful--
rmarkdown::render(x)
I tried all of the solutions proposed in this initial post.
This behaviour does not seem to be isolated to :=, but also some of the NSE within data.table as well. For instance:
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(dplyr)
library(data.table)
.datatable.aware = TRUE
dat <- data.table(x = rnorm(100),
y = rnorm(100),
grouper = sample(letters, 100, replace = TRUE),
date = seq.Date(Sys.Date(), length.out = 100, by = 1))
dat[,.SD[which.min(date)], by = grouper]
```
With:
x <- "test.Rmd"
purrr::map(x, rmarkdown::render)
# Error in which.min(date) :
# cannot coerce type 'closure' to vector of type 'double'
The solution at this point from the purrr side is to use anonymous function, but maybe adding purrr to the whitelist would help other users.
Output of sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1
When using data.table in an Rmd document and then trying to use
purrr::map
to apply thermarkdown::render
function the Rmd is nolonger data.table aware and rendering fails.More details in https://github.com/tidyverse/purrr/issues/789#issue-682118090.
Minimal reproducible example
Reprex:
---Rmarkdown contents saved as test.Rmd---
In a separate script I do the following:
I tried all of the solutions proposed in this initial post. This behaviour does not seem to be isolated to
:=
, but also some of the NSE within data.table as well. For instance:With:
The solution at this point from the
purrr
side is to use anonymous function, but maybe addingpurrr
to the whitelist would help other users.Output of sessionInfo()