Objects can be saved and read like so
# Save as file
saveRDS(iris, "mydata.RDS")
# Read back in
readRDS("mydata.RDS")
But this doesn't seem to work for objects made with xml2::read_html()
Example
library(rvest)
someobject <- read_html("https://stackoverflow.com/")
saveRDS(someobject, "someobject.RDS")
Which creates a file, but not as expected i.e.
readRDS("someobject.RDS")
Error in doc_is_html(x$doc) : external pointer is not valid
What's going on and what's the simplest way of saving an html object so that it can be loaded back in with minimal code/fuss?