'Missing Values and Row Shifting
I try and import a table from wikipedia and both lose values for the last column and can not seem to shift the offset rows over to clean the table. This is what I can import so far:
library(httr)
library(XML)
library(dplyr)
library(hacksaw)
url <- "https://en.wikipedia.org/wiki/Democracy_Index"
r <- GET(url)
doc <- readHTMLTable(doc = content(r, "text"))
by_country <- data.frame(doc[7])
names(by_country) <- as.matrix(by_country[1, ])
by_country <- by_country[-1, ]
by_country[] <- lapply(by_country, function(x) type.convert(as.character(x)))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
