Hacker News new | ask | show | jobs
by thmcmahon 3696 days ago
How'd you go with wrapping the websocket client in R? I've been putting together an R client and am stuck on how to do the websocket given the lack of R websocket libraries.
1 comments

I think your best bet is wrapping an existing C++ library using RCpp[1] that will require some work but I hope not too much.

[1] I would have really liked that as I ended up writing all data to SQLite and then imported it to R for analysis. Not the most elegant solution...

That is exactly what I am (currently) doing. Its actually a little tricky because of the stream-like nature of websockets. Currently I'm just writing to a file, but ideally I'd like to use the R connection API. The issue with that is that there doesn't appear to be a Rcpp wrapper around that particular API so I may have to do that (or test my theories by just using scan to read from the file after using a c++ binary to write it (using system).

Its a dirty hack, but appears to work.

FWIW, websocketpp is the C++ library I'm using.

Maybe not the most elegant solution, but it could be worse: I wrote all the data to a csv file and then imported into Excel for analysis.