# TimeLinePlot: Better way to get the data?

Posted 5 months ago
801 Views
|
3 Replies
|
3 Total Likes
|
 I'm a dabbler, no master and figure there have to be a better way too do this. I want to show how long it has taken to get to the next million cases of COVID in the US. I can get the data and get the result am looking for, but it feels like I'm doing it the hard way. How could I do this so I get a TimeLinePlot, but do not have to add each Select individually? ndata = Total[ Normal@ResourceData[ "Epidemic Data for Novel Coronavirus COVID-19"][ Select[MatchQ[Entity["Country", "UnitedStates"], #Country] && ! MissingQ[#AdministrativeDivision] &]][ All, #ConfirmedCases &]]; ntl = Take[ Transpose[ Flatten[{Take [Select[Normal[ndata], Last[#] < 1000000 &], -1], Take [Select[Normal[ndata], Last[#] < 2000000 &], -1], Take [Select[Normal[ndata], Last[#] < 3000000 &], -1], Take [Select[Normal[ndata], Last[#] < 4000000 &], -1]}, 1]], 1]; TimelinePlot[ntl] 
3 Replies
Sort By:
Posted 5 months ago
 Michael:I think I figured out how to get the data given a list of countries: covidData = ResourceData["Epidemic Data for Novel Coronavirus COVID-19"]; getData[country_String] := Normal@covidData[ Select[MatchQ[Entity["Country", country], #Country] && ! MissingQ[#AdministrativeDivision] &], "ConfirmedCases"]; ndata = Map[ getData, {"UnitedStates", "Canada", "UnitedKingdom} ] // Flatten // Total; But I am still learning about TimeSeries. And can't figure out how to use what is returned. I think I am close, but I have run out of time. I hope this helps.Have a great and safe weekend.
 Hi Michael,Here is one way to do it. BlockMap[(If[ Floor[Last@Last@#, 10^6] - Floor[Last@First@#, 10^6] >= 10^6, First@First@#, Nothing] &), ndata // Normal, 2, 1] // Flatten // TimelinePlot