{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "using DelimitedFiles" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "covidbycountry = DelimitedFiles.readdlm(\"who_covid_trans.csv\",',',header=false);" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#? writedlm" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "115×213 Array{Any,2}:\n", " \"Date\" \"China\" \"Singapore\" … \"Mauritania\" \"Comoros\"\n", " \"1/21/2020\" 278 0 0 0 \n", " \"1/22/2020\" 309 0 0 0 \n", " \"1/23/2020\" 571 0 0 0 \n", " \"1/24/2020\" 830 1 0 0 \n", " \"1/25/2020\" 1297 3 … 0 0 \n", " \"1/26/2020\" 1985 3 0 0 \n", " \"1/27/2020\" 2741 4 0 0 \n", " \"1/28/2020\" 4537 7 0 0 \n", " \"1/29/2020\" 5997 7 0 0 \n", " \"1/30/2020\" 7736 10 … 0 0 \n", " \"1/31/2020\" 9720 13 0 0 \n", " \"02/01/2020\" 11821 16 0 0 \n", " ⋮ ⋱ \n", " \"05/02/2020\" 84388 17101 8 1 \n", " \"05/03/2020\" 84393 17548 8 3 \n", " \"05/04/2020\" 84400 18205 … 8 3 \n", " \"05/05/2020\" 84404 18778 8 4 \n", " \"05/06/2020\" 84406 19410 8 4 \n", " \"05/07/2020\" 84409 20198 8 8 \n", " \"05/08/2020\" 84415 20939 8 8 \n", " \"05/09/2020\" 84416 21707 … 8 8 \n", " \"05/10/2020\" 84430 22460 8 11 \n", " \"05/11/2020\" 84450 23336 8 11 \n", " \"05/12/2020\" 84451 23822 8 11 \n", " \"5/13/2020\" 84458 24671 8 11 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "covidbycountry" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "213-element Array{Any,1}:\n", " \"Date\" \n", " \"China\" \n", " \"Singapore\" \n", " \"Japan\" \n", " \"Republic of Korea\"\n", " \"Philippines\" \n", " \"Australia\" \n", " \"Malaysia\" \n", " \"New Zealand\" \n", " \"Vietnam\" \n", " \"Brunei Darussalam\"\n", " \"Cambodia\" \n", " \"Mongolia\" \n", " ⋮ \n", " \"South Sudan\" \n", " \"Malawi\" \n", " \"Eritrea\" \n", " \"Angola\" \n", " \"Zimbabwe\" \n", " \"Botswana\" \n", " \"Burundi\" \n", " \"Gambia\" \n", " \"Namibia\" \n", " \"Seychelles\" \n", " \"Mauritania\" \n", " \"Comoros\" " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "namesofcolums = covidbycountry[1,:]" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "getindexbycountryname (generic function with 1 method)" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function getindexbycountryname(name::String)\n", " for i in 1:length(namesofcolums)\n", " if lowercase(name) == lowercase(namesofcolums[i])\n", " return i\n", " end\n", " end\n", "end" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "119" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "getindexbycountryname(\"Mexico\")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "covidbycountry = covidbycountry[2:end,:];" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "114-element Array{Any,1}:\n", " \"1/21/2020\" \n", " \"1/22/2020\" \n", " \"1/23/2020\" \n", " \"1/24/2020\" \n", " \"1/25/2020\" \n", " \"1/26/2020\" \n", " \"1/27/2020\" \n", " \"1/28/2020\" \n", " \"1/29/2020\" \n", " \"1/30/2020\" \n", " \"1/31/2020\" \n", " \"02/01/2020\"\n", " \"02/02/2020\"\n", " ⋮ \n", " \"05/02/2020\"\n", " \"05/03/2020\"\n", " \"05/04/2020\"\n", " \"05/05/2020\"\n", " \"05/06/2020\"\n", " \"05/07/2020\"\n", " \"05/08/2020\"\n", " \"05/09/2020\"\n", " \"05/10/2020\"\n", " \"05/11/2020\"\n", " \"05/12/2020\"\n", " \"5/13/2020\" " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "col1 = covidbycountry[:,1]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "using Dates" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "for i in 1:length(col1)\n", " col1[i] = Dates.DateTime(col1[i], \"m/d/y\")\n", "end" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "114-element Array{Any,1}:\n", " 2020-01-21T00:00:00\n", " 2020-01-22T00:00:00\n", " 2020-01-23T00:00:00\n", " 2020-01-24T00:00:00\n", " 2020-01-25T00:00:00\n", " 2020-01-26T00:00:00\n", " 2020-01-27T00:00:00\n", " 2020-01-28T00:00:00\n", " 2020-01-29T00:00:00\n", " 2020-01-30T00:00:00\n", " 2020-01-31T00:00:00\n", " 2020-02-01T00:00:00\n", " 2020-02-02T00:00:00\n", " ⋮ \n", " 2020-05-02T00:00:00\n", " 2020-05-03T00:00:00\n", " 2020-05-04T00:00:00\n", " 2020-05-05T00:00:00\n", " 2020-05-06T00:00:00\n", " 2020-05-07T00:00:00\n", " 2020-05-08T00:00:00\n", " 2020-05-09T00:00:00\n", " 2020-05-10T00:00:00\n", " 2020-05-11T00:00:00\n", " 2020-05-12T00:00:00\n", " 2020-05-13T00:00:00" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "col1" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dayssince (generic function with 1 method)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dayssince(x) = Dates.datetime2rata(col1[length(col1)]) - Dates.datetime2rata(x)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "epidays = Array{Int64}(undef,length(col1));" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "for i = 1:length(col1)\n", " epidays[i] = abs(dayssince(col1[i]))\n", "end" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "epidays = epidays[end:-1:1,end:-1:1];" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "114×1 Array{Int64,2}:\n", " 0\n", " 1\n", " 2\n", " 3\n", " 4\n", " 5\n", " 6\n", " 7\n", " 8\n", " 9\n", " 10\n", " 11\n", " 12\n", " ⋮\n", " 102\n", " 103\n", " 104\n", " 105\n", " 106\n", " 107\n", " 108\n", " 109\n", " 110\n", " 111\n", " 112\n", " 113" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "epidays" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "114×1 Array{Int64,2}:\n", " 0\n", " 1\n", " 2\n", " 3\n", " 4\n", " 5\n", " 6\n", " 7\n", " 8\n", " 9\n", " 10\n", " 11\n", " 12\n", " ⋮\n", " 102\n", " 103\n", " 104\n", " 105\n", " 106\n", " 107\n", " 108\n", " 109\n", " 110\n", " 111\n", " 112\n", " 113" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "covidbycountry[:,1] = epidays;" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "row,col =size(covidbycountry)\n", "for j = 1:col\n", " for i = 1:row\n", " covidbycountry[i,j] = Int(covidbycountry[i,j])\n", " end\n", "end" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "114×213 Array{Int64,2}:\n", " 0 278 0 1 1 0 … 0 0 0 0 0 0 0 0 0\n", " 1 309 0 1 1 0 0 0 0 0 0 0 0 0 0\n", " 2 571 0 1 1 0 0 0 0 0 0 0 0 0 0\n", " 3 830 1 1 2 0 0 0 0 0 0 0 0 0 0\n", " 4 1297 3 3 2 0 0 0 0 0 0 0 0 0 0\n", " 5 1985 3 3 2 0 … 0 0 0 0 0 0 0 0 0\n", " 6 2741 4 4 4 0 0 0 0 0 0 0 0 0 0\n", " 7 4537 7 6 4 0 0 0 0 0 0 0 0 0 0\n", " 8 5997 7 7 4 0 0 0 0 0 0 0 0 0 0\n", " 9 7736 10 11 4 1 0 0 0 0 0 0 0 0 0\n", " 10 9720 13 14 11 1 … 0 0 0 0 0 0 0 0 0\n", " 11 11821 16 17 12 1 0 0 0 0 0 0 0 0 0\n", " 12 14411 18 20 15 2 0 0 0 0 0 0 0 0 0\n", " ⋮ ⋮ ⋱ ⋮ ⋮ \n", " 102 84388 17101 14545 10780 8772 29 34 23 15 12 16 11 8 1\n", " 103 84393 17548 14839 10793 8928 35 34 23 19 17 16 11 8 3\n", " 104 84400 18205 15057 10801 9223 35 34 23 19 17 16 11 8 3\n", " 105 84404 18778 15231 10804 9485 … 35 34 23 19 17 16 11 8 4\n", " 106 84406 19410 15354 10806 9684 36 34 23 19 17 16 11 8 4\n", " 107 84409 20198 15463 10810 10004 36 34 23 19 17 16 11 8 8\n", " 108 84415 20939 15547 10822 10343 36 34 23 19 18 16 11 8 8\n", " 109 84416 21707 15649 10840 10463 36 34 23 19 20 16 11 8 8\n", " 110 84430 22460 15747 10874 10610 … 43 35 23 19 20 16 11 8 11\n", " 111 84450 23336 15798 10909 10794 45 36 23 19 20 16 11 8 11\n", " 112 84451 23822 15874 10936 11086 45 36 24 19 22 16 11 8 11\n", " 113 84458 24671 16024 10962 11350 45 37 24 27 23 16 11 8 11" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "covidbycountry = convert(Array{Int64,2},covidbycountry);" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m registry at `~/.julia/registries/General`\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m git-repo `https://github.com/JuliaRegistries/General.git`\n", "\u001b[?25l\u001b[2K\u001b[?25h\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.2/Project.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.2/Manifest.toml`\n", "\u001b[90m [no changes]\u001b[39m\n" ] } ], "source": [ "#using Pkg\n", "#Pkg.add(\"Plots\")" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "┌ Info: Recompiling stale cache file /Users/eddie/.julia/compiled/v1.2/Plots/ld3vC.ji for Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]\n", "└ @ Base loading.jl:1240\n" ] } ], "source": [ "using Plots" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Plots.GRBackend()" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gr()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "covidbycountry[:,119]" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" }, { "name": "stderr", "output_type": "stream", "text": [ "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n" ] } ], "source": [ "plot(covidbycountry[:,1],[covidbycountry[:,119] covidbycountry[:,2]],linetype= :scatter, \n", " marker= (:diamond,5),\n", " title = \"COVID-19 Compaarisson China/Mexico\",\n", " xlabel = \"Days since 21 January 2020\",\n", " ylabel = \"Total cases to date\",\n", " label = [\"Mexico\" \"China\"]\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.2.0", "language": "julia", "name": "julia-1.2" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.2.0" } }, "nbformat": 4, "nbformat_minor": 4 }