Error messages in Console



I’m brand new to R. In fact, I’m building my first project by copying an article from

However, I’m getting errors and I have no idea how to fix them. I input the following by copying the script from the article and updating with my specifics:

for (name in San_Diego_Foundations$NAME[1:667]){ 
  print(paste0(“finding the url for:”,name)) 


  url1 = URLencode(paste0("",name)) 
  page1 <- read_html(url1) 
  results1 <- page1 %>% html_nodes(“cite”) %>% html_text() 
  result1 <- as.character(results1[1]) 

  San_Diego_Foundations[San_Diego_Foundations$NAME==name,]$Website <- result1 


This is what the console replied:

> for (name in San_Diego_Foundations$NAME[1:667]){ 
+     print(paste0(“finding the url for:”,name)) 
Error: unexpected input in:
>     Sys.sleep(3)  
>     url1 = URLencode(paste0(“",name)) 
Error: unexpected input in "    url1 = URLencode(paste0(“"
>                              page1 <- read_html(url1) 
Error in read_html(url1) : could not find function "read_html"
>                              results1 <- page1 %>% html_nodes(“cite”) %>% html_text() 
Error: unexpected input in "                             results1 <- page1 %>% html_nodes(“"
>                              result1 <- as.character(results1[1]) 
Error: object 'results1' not found
>                              San_Diego_Foundations[San_Diego_Foundations$NAME==name,]$Website <- result1 
Error: object 'result1' not found
> }
Error: unexpected '}' in "}"


The first quote here is educated, but the second is straight. Change the first one to ".

This is a function from rvest, which has to be loaded with library(rvest) at the beginning of the script (after previously being installed with install.packages("rvest")).

Most of the rest of the errors look like snowballs from those two, but it would be much easier to see if you could edit your post and format it as code, e.g. by highlighting it and clicking the </> button (or just putting it between pairs of triple backticks (```). (For more details, see a Markdown cheatsheet.)


Hi alistaire,

I changed the quote as you indicated (and several more I saw in my syntax) and loaded rvest using library(rvest) - the article I was following said to load the library use require(“rvest”). Then I ran the script in the console again, so I could regenerate the error messages formatted as code but…voila! My script is running now.

Thank you so very much for your reply.


@R_Noob if you question has been answered, can you please mark it as correct so that future users viewing this thread can quickly identify what helped you.

If you click the three dots next to the reply button on the post that solved your problem you should see a box with a check mark as one of the options. Please select that.