{
"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": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"getindexbycountryname (generic function with 1 method)"
]
},
"execution_count": 6,
"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": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"114"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"getindexbycountryname(\"United States of America\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"covidbycountry = covidbycountry[2:end,:];"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"col1 = covidbycountry[:,1]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"using Dates"
]
},
{
"cell_type": "code",
"execution_count": 11,
"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": 12,
"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": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"col1"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dayssince (generic function with 1 method)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dayssince(x) = Dates.datetime2rata(col1[length(col1)]) - Dates.datetime2rata(x)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"epidays = Array{Int64}(undef,length(col1));"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"for i = 1:length(col1)\n",
" epidays[i] = abs(dayssince(col1[i]))\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"epidays = epidays[end:-1:1,end:-1:1];"
]
},
{
"cell_type": "code",
"execution_count": 17,
"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": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"epidays"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"covidbycountry[:,1] = epidays;"
]
},
{
"cell_type": "code",
"execution_count": 19,
"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": 20,
"metadata": {},
"outputs": [],
"source": [
"covidbycountry = convert(Array{Int64,2},covidbycountry);"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"#using Pkg\n",
"#Pkg.add(\"Plots\")"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"using Plots"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Plots.GRBackend()"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gr()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"114-element Array{Int64,1}:\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" 0\n",
" ⋮\n",
" 19224\n",
" 20739\n",
" 22088\n",
" 23471\n",
" 24905\n",
" 26025\n",
" 27634\n",
" 29616\n",
" 31522\n",
" 33460\n",
" 35022\n",
" 36327"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"covidbycountry[:,119]"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(covidbycountry[:,1],[covidbycountry[:,119] covidbycountry[:,2]],linetype= :scatter, \n",
" legend = :topleft,\n",
" marker= (:diamond,5),\n",
" title = \"COVID-19 Comparisson 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": 29,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(covidbycountry[:,1],covidbycountry[:,119],linetype= :scatter, \n",
" legend = :topleft,\n",
" marker = (:diamond,5),\n",
" title = \"COVID-19 Mexico cases\",\n",
" xlabel = \"Days since 21 January 2020\",\n",
" ylabel = \"Total cases to date\",\n",
" label = [\"Mexico\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(covidbycountry[:,1],[covidbycountry[:,119] covidbycountry[:,25]],linetype= :scatter, \n",
" legend = :topleft,\n",
" marker= (:diamond,5),\n",
" title = \"COVID-19 Comparisson Germany/Mexico\",\n",
" xlabel = \"Days since 21 January 2020\",\n",
" ylabel = \"Total cases to date\",\n",
" label = [\"Mexico\" \"Germany\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(covidbycountry[:,1],[covidbycountry[:,114] covidbycountry[:,25]],linetype= :scatter, \n",
" marker= (:diamond,5),\n",
" title = \"COVID-19 Comparisson Germany/USA\",\n",
" xlabel = \"Days since 21 January 2020\",\n",
" ylabel = \"Total cases to date\",\n",
" label = [\"USA\" \"Germany\"]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(covidbycountry[:,1],[covidbycountry[:,119] covidbycountry[:,114]],linetype= :scatter, \n",
" marker= (:diamond,5),\n",
" title = \"COVID-19 Comparisson Mexico/USA\",\n",
" xlabel = \"Days since 21 January 2020\",\n",
" ylabel = \"Total cases to date\",\n",
" label = [\"Mexico\" \"USA\"]\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
}