covid.ijs 1.0 KB

12345678910111213141516171819202122232425262728
  1. NB. COVID-19 Data Filtering by Contry and Ploting
  2. require 'tables/csv web/gethttp plot'
  3. NB. Utility verbs
  4. gets =: 4 : '(I. (<y) E. 0{|:x){x'
  5. lreg =: 4 : 'y %. 1 ,. x'
  6. treg =: 3 : '((1{((i.#y) lreg y))*(i.#y))+(0{((i.#y) lreg y))'
  7. col =: 4 : 'makenum x { |: y' NB. adjust by adding }. if header=true
  8. columns =: 3 : '(;/ |: ,: i. #0{y) ,. (|: ,: 0{ y)'
  9. counter =: 3 : '(~. y) ,. (;/ (#/.~ y))'
  10. covid =: fixcsv gethttp dquote 'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv'
  11. NB. define country before applying lastndays
  12. country =: ''
  13. lnd =: 3 : '|. y {. |. 5 col covid gets country' NB. last n days
  14. report =: 3 : 0
  15. weekavg =: (+/%#) 7 |. lnd 7 NB. average daily infection for a week
  16. total =: {. |. 4 col covid gets country NB. returns last total infection
  17. cpm =: {. |. 9 col covid gets country NB. daily cases per million
  18. echo 'Average Weekly: ' , ":weekavg
  19. echo 'Total Cases in Country: ', ":total
  20. echo 'Daily Cases per Million: ',":cpm
  21. )