Trying to convert JSON url using the fromJSON() function, but it is not working (never finishes running) - r

My code:
library(jsonlite)
URL = "https://stats.nba.com/stats/playbyplayv2?EndPeriod=10&EndRange=55800&GameID=0021500431&RangeType=2&StartPeriod=1&StartRange=0"
the.data.file <- fromJSON(URL)
Simple, right? However, the code never stops running. No error message pops up, it just goes on forever. I thought maybe it just takes some time, but it's been going on for a long time. Maybe that's normal, and let me know if it is, but I don't think that's the case.

Self-Answer (not sure if I'm supposed to do this?):
I did more testing with the fromJSON() function and found out that it works fine with other URLs. So I wondered if the problem was with stats.nba.com and looked up this problem specific to stats.nba.com, and sure enough I found other people asking the same thing. The solution that worked for me is downloading the file similar to this:
library(jsonlite)
curl_download("http://stats.nba.com/stats/teamgamelog?LeagueID=00&Season=2016-17&SeasonType=Regular+Season&teamid=1610612761", "nba.json")
jsonlist<-fromJSON( "nba.json")
df<-as.data.frame(jsonlist$resultSets$rowSet)
names(df)<-jsonlist$resultSets$headers[[1]]
parameters<-jsonlist$parameters
I don't want to take credit for this because I found it from another user's answer here. I'm just putting it here in case somebody in the future finds it.

Related

How to use syntax highlighting in next js?

I am able to parse the markdwon with the help of remark and remark-html. How can I add syntax highlighting features for the code element?
I've been searched for TWO whole days trying to use remark/rehype ecosystem on syntax highlighting which is way more complex to use. I'm still working on searching, it's better to avoid remark/rehype ecosystem and try another method.
Here I share list of my search, just give you some subjective perspective so that you won't waste you too much time on things that not working. None of them will work as you expected, and their sample code are obscure or just broken codes.
https://github.com/remarkjs/remark-highlight.js
They move to support rehype. Are you a big fan of them wanna move as well?
https://github.com/sergioramos/remark-prism
You will get this error: Module parse failed: Unexpected character '�'
https://github.com/torchlight-api/remark-torchlight
They states on their website: 🚨 This client is still very much a work in progress. Please open issues! 🚨View it on github at github.com/torchlight-api/remark and this link is invalid.
https://github.com/rehypejs/rehype-highlight
It force you to use rehpye althought you can you remark-rehype for you to transfer easily. However, debug your code once you encounter some error will be helpless.
sample code use third-pary v-file to read file showing their code is working but not. and it reads html file not markdown file.
It's hard for you to grasp their concept to use their plugins to easily. It waste most of you valuable time to think what they think.
I give up remark/rehype ecosystem and stay away from them. Good luck! :)

RData file loads into memory, then is entirely inaccessible

I received an .Rdata file from a colleague that I am trying to load into memory on my own server. When I attempt to use load('./myfile.Rdata'), everything appears to work (i.e. the machine thinks for a while and doesn't throw any error message), but then ls() simply returns character(0).
I've tried the above, as well as trying load('./myfile.Rdata', verbose = TRUE) to confirm that something is happening during loading. Indeed, when I do so, I get
Loading objects:
dtn
dtn is the expected name of the object, so that's all fine and well. Again, when I then try to do anything with dtn, I'm told there is no such object, and ls() continues to return character(0).
Unfortunately I can't seem to recreate the problem in any way that I can share here, short of sharing the actual file which I cannot do.
I've never experienced this problem before, and have no idea what to make of it. Any help would be greatly appreciated.

Fastest way to send multiple http requests in R

You can use multithreading in Python and send lots of http requests, like in this SO question. My question is, is there any easy way to do this in R? I've seen a guide for RCurl here, but I'd prefer a simpler solution if possible. Currently I'm looping through a series of ids, it's be great to send all (or more) of them at once.
That guide to multiple requests in Rcurl looks pretty simple, in fact I'd say it looks simpler to me than the solution to the Python question you've linked. Better yet, the work is already done for you. Most of that guide is going into detail about the advantages of concurrent requests; the method itself is deceptively simple, and is provided for you pre-cooked right at the top of the page.
You can literally cut and paste the code shown at the top of the post into an R script (include library(RCurl) above it), run that code to source the function, then call the function with a single line.
I won't paste the function code here, since you should get that from its author, but once you've sourced that function, their example usage is:
uris = c("http://www.omegahat.org/index.html", "http://www.omegahat.org/RecentActivities.html")
z <- getURIs(uris)
I just did the above on my own computer, and it works perfectly. I'd be surprised if you can find a simpler solution than that.

HTK ERROR [+5010] InitSource: Cannot open source file f-ihm+k

I believe that this error has something to do with a mismatch between my tiedlist and the hmmdefs (as pointed out here:http://www.ling.ohio-state.edu/~bromberg/htk_problems.html), but I can not seem to solve it. All of the triphones in my corpus are present in my triphones1 list and triphones1 only contains monophones,biphones and triphones from my corpus.
If I take said triphone out of the triphones1 list and recreate the tiedlist it passes but complains about another triphone down the road. Obviously manually taking out all of these triphones would take me years and it doesn't seem efficient which leads me to believe that I have missed something further back.
It is also important to note that all these triphones generating errors are in my corpus as well. To me this error would only make sense if I had unseen triphones somewhere, but where? I feel that I have left no stone unturned but surely someone can give me a fresh idea of where to look.
There was an extra AU command at the end of the tree.hed file This was causing it to try and open another file after the tiedlist. I am not sure why this causes an issue when it has already accessed tiedlist, but there you go.
Hopefully this serves as a extra check for future htk users.

How do you obtain time-based paths?

I am working on a script for a Linux machine to look through a time-based path at a certain time, but I have no experience with time-based paths and resources on this topic seem quite limited even though this should be pretty straightforward.
An example would be to look into the path /home/temp/test/[Current Date]. I vaguely remember it being along the lines of /home/temp/test/%m/%d/%y, but I am not confident. Within /home/temp/, there will be multiple directories with separate dates. Any insights would be greatly appreciated.
Ok so through some more testing, I figured it out. It was pretty close to what I initially had. To specify the time in the path, it really is as straight forward as /home/temp/test/%Y%d%m. I made the mistake of attempting to glob which was a separate error and I interpreted as a related error. Sorry about that.

Resources