Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve 'Input must be a vector, not an environment' when crawling website with R

Tags:

r

rvest

I am crawling a website to R but error pops up: ! Input must be a vector, not an environment.

I attempt to crawl a website by doing

` simple <- read_html("https://en.wikipedia.org/wiki/Kargil_War")

a <- simple %>% html_nodes("p") %>% html_text() `

The code works at the beginning but error pops up later: Error in stop_vctrs(): ! Input must be a vector, not an environment. Run rlang::last_error() to see where the error occurred.

How can I solve this? Thank you!

like image 454
robot101 Avatar asked Jan 27 '26 08:01

robot101


2 Answers

I've seen this error when using version 1.5.0 of the stringr package. Reverting to stringr version 1.4.0 fixed your example for me.

require(devtools)
install_version("stringr", version = "1.4.0" )
like image 78
Rob Avatar answered Jan 28 '26 23:01

Rob


Had the same problem, updating the vctrs worked for me.

install.packages("vctrs")
like image 42
JavRoNu Avatar answered Jan 28 '26 22:01

JavRoNu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!