I am new to R. I am trying to scrape data from wikipedia but o/p is not in readable format.
Below is my code:
library("rvest")
library("xml2")
library("magrittr")
library("tidyverse")
wiki_url <- "https://en.wikipedia.org/wiki/List_of_countries_by_intentional_homicide_rate"
population <- wiki_url %>%
read_html() %>%
html_nodes(xpath='//*[@id="mw-content-text"]/div/table[2]') %>%
html_table(fill = TRUE)
O/P:
[[1]]
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22
X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 X41 X42
.
.
.
.
X1843 X1844 X1845 X1846 X1847 X1848 X1849 X1850 X1851 X1852 X1853 X1854 X1855
X1856 X1857 X1858
[ reached 'max' / getOption("max.print") -- omitted 465 rows ]
I want all columns and rows in table format only.