When I first run the code below, everything is ok. But when I change something in html_file %>%...
comand, for example commenting tolower()
, I get the following error:
Error: target title failed.
diagnose(title)error$message:
external pointer is not valid
diagnose(title)error$calls:
1. └─html_file %>% html_nodes("h2") %>% html_text()
Code:
library(rvest)
library(drake)
some_string <- '
<div class="main">
<h2>A</h2>
<div class="route">X</div>
</div>
'
html_file <- read_html(some_string)
title <- html_file %>%
html_nodes("h2") %>%
html_text()
plan <- drake_plan(
html_file = read_html(some_string),
title = html_file %>%
html_nodes("h2") %>%
html_text() %>%
tolower()
)
make(plan)
I found two possible solutions but I'm not enthusiastic about them.
1. Join both steps in drake_plan
into one.
2. Use xml2::write_html()
and xml2::read_html()
as suggested here.
Is there a better way to solve it?
P.S. Issue was already discussed here, Rstudio forum, and on github.