0

I'm scrapping with rvest and I have trouble with filling the empty values with NA.

The first section extracts the nodes, for this example I get 65 results. But on the "trebol" values I only get 11 and i want to fill the rest of the values with NA to complete de dataframe with the corresponding values.

I hope it's clear, I'm pretty new here..

library(rvest)
library(stringr)
library(tidyverse)
library(dplyr)
hoteles_verdes  <- read_html('Boston_Mayo 2022.html') # file name

hoteles_verdes %>%
  html_nodes("div.a826ba81c4") %>%
  html_text()

trebol <- hoteles_verdes %>% 
  html_elements("span.a51f4b5adb")%>%
  html_text() 

hotelesDF <- tibble(nombres, tarifa, trebol, distancia, links) #here I create the data frame with the rest of the thing i extracted that have 65 results
maru1898
  • 23
  • 2
  • Does this answer your question::https://stackoverflow.com/questions/56673908/how-do-you-scrape-items-together-so-you-dont-lose-the-index/56675147#56675147 – Dave2e May 02 '22 at 21:58
  • Could you give us you the link to the website or your html file? – Emmanuel Hamel Apr 17 '23 at 04:17

0 Answers0