ReadHTMLTable problems in R

I tried to use readHTMLTable to store some data in a dataframe in R Studio, but it just keeps saying that it couldn't find the "ReadHTMLTable" function. I don't understand where I went wrong. Can someone take a lot on this and tell me how I can fix this? or if it works in your R studio .

url <- 'http://www.cdc.gov/vhf/ebola/outbreaks/2014-west-africa/case-counts.html'
ebola <- getURL(url)
ebola <- readHTMLTable(ebola, stringAsFactors = F)

Error: could not find function "readHTMLTable"

      

+3


source to share


1 answer


You are reading the table with R default, which converts characters to factors. You can use stringsAsFactors = FALSE

in readHTMLTable

and it will be passed to data.frame

. Also the table uses commas for thousands of separators that you need to remove:



library(XML)
url1 <-'http://en.wikipedia.org/wiki/List_of_Ebola_outbreaks'
df1<- readHTMLTable(url1, which = 2, stringsAsFactors = FALSE)
df1$"Human death"
mySum <- sum(as.integer(gsub(",", "", df1$"Human death")))
> mySum
[1] 6910

      

+2


source







All Articles