I have used revest to scrape wiki before but this time I can't gather the data from a collapsible table (first table of the post):
library(tidyverse)
library(rvest)
url <- "https://es.wikipedia.org/wiki/Anexo:Sondeos_de_intenci%C3%B3n_de_voto_para_las_elecciones_generales_de_Espa%C3%B1a_de_noviembre_de_2019"
sample <- url %>%
read_html() %>%
html_nodes(xpath = '/html/body/div[3]/div[3]/div[4]/div/table[1]') %>%
html_table(header = T)
I get this error message:
Error in if (length(p) > 1 & maxp * n != sum(unlist(nrows)) & maxp * n != : missing value where TRUE/FALSE needed
I have the feeling that this is due to the nested cells but I can't find a way to delete the first and last rows.