christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
652 stars 268 forks source link

convert examples to use curl package #284

Open dmenne opened 3 years ago

dmenne commented 3 years ago

windows 10, problem with RCurls and TLS

URL <- "https://raw.githubusercontent.com/christophergandrud/d3Network/sankey/JSONdata/energy.json"
Energy <- RCurl::getURL(URL, ssl.verifypeer = TRUE)

>Error in function (type, msg, asError = TRUE)  : 
  error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

RCurl::curlVersion()$ssl_version
>> [1] "OpenSSL/1.0.0o"
cjyetman commented 3 years ago

This is not the repo for RCurl, so if you want that error specifically to be addressed, you'll probably have to report it to the developers of that package.

In order to get examples here working that use RCurl to get the data, you could instead use the more modern pkg curl. For example...

library(curl)
library(jsonlite)
library(networkD3)

URL <- "https://raw.githubusercontent.com/christophergandrud/d3Network/sankey/JSONdata/energy.json"
energy <- fromJSON(curl(URL))

EngLinks <- energy$links
EngNodes <- energy$nodes

sankeyNetwork(Links = EngLinks, Nodes = EngNodes, Source = "source",
              Target = "target", Value = "value", NodeID = "name",
              fontSize = 12, nodeWidth = 30)
dmenne commented 3 years ago

Yes, I know this is not the curl repo, and I got it to work anyway. Just a report for easy correction in your markdown example