¿Cómo puedo usar un bucle para raspar los datos del sitio web para varias páginas web en R?

Me gustaría aplicar un bucle para raspar datos de varias páginas web en R. Puedo raspar los datos de una página web, sin embargo, cuando intento usar un bucle para varias páginas, recibo un error frustrante. He pasado horas jugando, sin resultado. Cualquier ayuda sería muy apreciada!

Esto funciona:

###########################
# GET COUNTRY DATA
###########################

library("rvest")

site <- paste("http://www.countryreports.org/country/","Norway",".htm", sep="")
site <- html(site)

stats<-
    data.frame(names =site %>% html_nodes(xpath="//*/td[1]") %>% html_text() ,
         facts =site %>% html_nodes(xpath="//*/td[2]") %>% html_text() ,
         stringsAsFactors=FALSE)

stats$country <- "Norway"
stats$names   <- gsub('[\r\n\t]', '', stats$names)
stats$facts   <- gsub('[\r\n\t]', '', stats$facts)
View(stats)

Sin embargo, cuando intento escribir esto en un bucle, recibo un error

###########################
# ATTEMPT IN A LOOP
###########################

country<-c("Norway","Sweden","Finland","France","Greece","Italy","Spain")

for(i in country){

site <- paste("http://www.countryreports.org/country/",country,".htm", sep="")
site <- html(site)

stats<-
data.frame(names =site %>% html_nodes(xpath="//*/td[1]") %>% html_text() ,
         facts =site %>% html_nodes(xpath="//*/td[2]") %>% html_text() ,
       stringsAsFactors=FALSE)

stats$country <- country
stats$names   <- gsub('[\r\n\t]', '', stats$names)
stats$facts   <- gsub('[\r\n\t]', '', stats$facts)

stats<-rbind(stats,stats)
stats<-stats[!duplicated(stats),]
}

Error:

Error: length(url) == 1 is not TRUE
In addition: Warning message:
In if (grepl("^http", x)) { :
  the condition has length > 1 and only the first element will be used

Respuestas a la pregunta(3)

Su respuesta a la pregunta