Darkrider
Darkrider

Reputation: 79

Error while loading dataset in R-fiddle

How can i load datasets in my code when using R-fiddle. I tried getting it from a url but there were some errors

http://www.r-fiddle.org/#/fiddle?id=S4A74L4E

Upvotes: 0

Views: 1965

Answers (1)

Rorschach
Rorschach

Reputation: 32466

It looks like you need to upload your data to publicly visible url. Here is an example where I put the output from some data (dput(dat)) onto pastebin. rvest isn't available on R fiddle apparently, but using XML library, you can then scrape the data from the pastebin page.

library(XML)
mydat <- "http://pastebin.com/hPN1GLyw"

stuff <- htmlParse(mydat)

li <- getNodeSet(stuff, "//div[@class=\'text\']")
dat <- eval(parse(text=xmlSApply(li, xmlValue)))

dat
#    lodi dodi
# 1     1   10
# 2     2    9
# 3     3    8
# 4     4    7
# 5     5    6
# 6     6    5
# 7     7    4
# 8     8    3
# 9     9    2
# 10   10    1

Upvotes: 3

Related Questions