I'm trying to convert three lines of R code into an elegant one liner using %>% for a bit of fairly simple code that gets data from an API, transforms the Unicode into JSON and then into a char type that I can use as data.
Because I like slick, I wanted to make those three lines into one command using %>%, like so:
</>data <- fromJSON(rawToChar(res$content)) %>% GET("http://api.open-notify.org/astros.json")
But that fails with this error code:
Error in parse_url(url) : length(url) == 1 is not TRUE
Thank you so much - that worked like a charm! I had tried it the other way around at first but that didn't work either. I have not used '$' before, that is very neat. Thanks so much!