Last active
March 22, 2020 17:17
-
-
Save ccamara/6f81df1ef7798b13b6c233e638540ee2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCAA | date | total | ||
---|---|---|---|---|
1 | Andalucía | 16-03-20 | 0 | |
2 | Andalucía | 17-03-20 | 0 | |
3 | Andalucía | 18-03-20 | 38 | |
4 | Andalucía | 19-03-20 | 33 | |
5 | Andalucía | 20-03-20 | 72 | |
6 | Andalucía | 21-03-20 | 72 | |
7 | Andalucía | 22-03-20 | 38 | |
8 | Aragón | 16-03-20 | 0 | |
9 | Aragón | 17-03-20 | 0 | |
10 | Aragón | 18-03-20 | 0 | |
11 | Aragón | 19-03-20 | 0 | |
12 | Aragón | 20-03-20 | 0 | |
13 | Aragón | 21-03-20 | 0 | |
14 | Aragón | 22-03-20 | 3 | |
15 | Asturias | 16-03-20 | 3 | |
16 | Asturias | 17-03-20 | 3 | |
17 | Asturias | 18-03-20 | 4 | |
18 | Asturias | 19-03-20 | 4 | |
19 | Asturias | 20-03-20 | 12 | |
20 | Asturias | 21-03-20 | 16 | |
21 | Asturias | 22-03-20 | 20 | |
22 | Baleares | 16-03-20 | 1 | |
23 | Baleares | 17-03-20 | 1 | |
24 | Baleares | 18-03-20 | 4 | |
25 | Baleares | 19-03-20 | 6 | |
26 | Baleares | 20-03-20 | 10 | |
27 | Baleares | 21-03-20 | 11 | |
28 | Baleares | 22-03-20 | 17 | |
29 | Canarias | 16-03-20 | 7 | |
30 | Canarias | 17-03-20 | 8 | |
31 | Canarias | 18-03-20 | 8 | |
32 | Canarias | 19-03-20 | 9 | |
33 | Canarias | 20-03-20 | 6 | |
34 | Canarias | 21-03-20 | 7 | |
35 | Canarias | 22-03-20 | 7 | |
36 | Cantabria | 16-03-20 | 10 | |
37 | Cantabria | 17-03-20 | 10 | |
38 | Cantabria | 18-03-20 | 10 | |
39 | Cantabria | 19-03-20 | 10 | |
40 | Cantabria | 20-03-20 | 10 | |
41 | Cantabria | 21-03-20 | 11 | |
42 | Cantabria | 22-03-20 | 11 | |
43 | Castilla-La Mancha | 16-03-20 | 12 | |
44 | Castilla-La Mancha | 17-03-20 | 12 | |
45 | Castilla-La Mancha | 18-03-20 | 15 | |
46 | Castilla-La Mancha | 19-03-20 | 27 | |
47 | Castilla-La Mancha | 20-03-20 | 34 | |
48 | Castilla-La Mancha | 21-03-20 | 38 | |
49 | Castilla-La Mancha | 22-03-20 | 48 | |
50 | Castilla y León | 16-03-20 | 5 | |
51 | Castilla y León | 17-03-20 | 5 | |
52 | Castilla y León | 18-03-20 | 5 | |
53 | Castilla y León | 19-03-20 | 27 | |
54 | Castilla y León | 20-03-20 | 37 | |
55 | Castilla y León | 21-03-20 | 54 | |
56 | Castilla y León | 22-03-20 | 89 | |
57 | Cataluña | 16-03-20 | 0 | |
58 | Cataluña | 17-03-20 | 0 | |
59 | Cataluña | 18-03-20 | 0 | |
60 | Cataluña | 19-03-20 | 0 | |
61 | Cataluña | 20-03-20 | 150 | |
62 | Cataluña | 21-03-20 | 150 | |
63 | Cataluña | 22-03-20 | 150 | |
64 | Ceuta | 16-03-20 | 0 | |
65 | Ceuta | 17-03-20 | 0 | |
66 | Ceuta | 18-03-20 | 0 | |
67 | Ceuta | 19-03-20 | 0 | |
68 | Ceuta | 20-03-20 | 0 | |
69 | Ceuta | 21-03-20 | 0 | |
70 | Ceuta | 22-03-20 | 0 | |
71 | C. Valenciana | 16-03-20 | 2 | |
72 | C. Valenciana | 17-03-20 | 12 | |
73 | C. Valenciana | 18-03-20 | 16 | |
74 | C. Valenciana | 19-03-20 | 19 | |
75 | C. Valenciana | 20-03-20 | 20 | |
76 | C. Valenciana | 21-03-20 | 25 | |
77 | C. Valenciana | 22-03-20 | 30 | |
78 | Extremadura | 16-03-20 | 4 | |
79 | Extremadura | 17-03-20 | 5 | |
80 | Extremadura | 18-03-20 | 6 | |
81 | Extremadura | 19-03-20 | 6 | |
82 | Extremadura | 20-03-20 | 7 | |
83 | Extremadura | 21-03-20 | 8 | |
84 | Extremadura | 22-03-20 | 8 | |
85 | Galicia | 16-03-20 | 4 | |
86 | Galicia | 17-03-20 | 7 | |
87 | Galicia | 18-03-20 | 7 | |
88 | Galicia | 19-03-20 | 4 | |
89 | Galicia | 20-03-20 | 5 | |
90 | Galicia | 21-03-20 | 6 | |
91 | Galicia | 22-03-20 | 16 | |
92 | Madrid | 16-03-20 | 474 | |
93 | Madrid | 17-03-20 | 951 | |
94 | Madrid | 18-03-20 | 951 | |
95 | Madrid | 19-03-20 | 941 | |
96 | Madrid | 20-03-20 | 1186 | |
97 | Madrid | 21-03-20 | 1542 | |
98 | Madrid | 22-03-20 | 1899 | |
99 | Melilla | 16-03-20 | 0 | |
100 | Melilla | 17-03-20 | 0 | |
101 | Melilla | 18-03-20 | 0 | |
102 | Melilla | 19-03-20 | 0 | |
103 | Melilla | 20-03-20 | 0 | |
104 | Melilla | 21-03-20 | 0 | |
105 | Melilla | 22-03-20 | 0 | |
106 | Murcia | 16-03-20 | 1 | |
107 | Murcia | 17-03-20 | 1 | |
108 | Murcia | 18-03-20 | 1 | |
109 | Murcia | 19-03-20 | 1 | |
110 | Murcia | 20-03-20 | 1 | |
111 | Murcia | 21-03-20 | 1 | |
112 | Murcia | 22-03-20 | 1 | |
113 | Navarra | 16-03-20 | 0 | |
114 | Navarra | 17-03-20 | 0 | |
115 | Navarra | 18-03-20 | 0 | |
116 | Navarra | 19-03-20 | 0 | |
117 | Navarra | 20-03-20 | 1 | |
118 | Navarra | 21-03-20 | 1 | |
119 | Navarra | 22-03-20 | 4 | |
120 | País Vasco | 16-03-20 | 5 | |
121 | País Vasco | 17-03-20 | 11 | |
122 | País Vasco | 18-03-20 | 14 | |
123 | País Vasco | 19-03-20 | 18 | |
124 | País Vasco | 20-03-20 | 21 | |
125 | País Vasco | 21-03-20 | 165 | |
126 | País Vasco | 22-03-20 | 216 | |
127 | La Rioja | 16-03-20 | 2 | |
128 | La Rioja | 17-03-20 | 2 | |
129 | La Rioja | 18-03-20 | 2 | |
130 | La Rioja | 19-03-20 | 2 | |
131 | La Rioja | 20-03-20 | 13 | |
132 | La Rioja | 21-03-20 | 18 | |
133 | La Rioja | 22-03-20 | 18 | |
134 | Total | 16-03-20 | 530 | |
135 | Total | 17-03-20 | 1028 | |
136 | Total | 18-03-20 | 1081 | |
137 | Total | 19-03-20 | 1107 | |
138 | Total | 20-03-20 | 1585 | |
139 | Total | 21-03-20 | 2125 | |
140 | Total | 22-03-20 | 2575 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
#' Converts datadista wide data into long data. | |
#' @description Converts datadista wide data into long data and stores it into a CSV file under data folder. | |
#' @param name A string to name resulting output file. | |
#' @param url A string with the url where data will be retreived from. | |
coviddataset_long <- function(name, url) { | |
df <- read.csv(url) %>% | |
select(-cod_ine) %>% | |
pivot_longer(-CCAA, names_to = "date", values_to = "total") %>% | |
mutate(date = gsub("X*", "", date)) %>% | |
mutate(date = gsub("\\.", "-", date)) %>% | |
mutate(date = as.Date(date)) | |
write.csv(df, paste0("data/output/", name, ".csv")) | |
} | |
coviddataset_long("ccaa_covid19_altas_long", "https://raw.githubusercontent.com/datadista/datasets/master/COVID%2019/ccaa_covid19_casos.csv") | |
coviddataset_long("ccaa_covid19_casos_long", "https://raw.githubusercontent.com/datadista/datasets/master/COVID%2019/ccaa_covid19_casos.csv") | |
coviddataset_long("ccaa_covid19_uci_long", "https://raw.githubusercontent.com/datadista/datasets/master/COVID%2019/ccaa_covid19_uci.csv") | |
coviddataset_long("ccaa_covid19_fallecidos_long", "https://raw.githubusercontent.com/datadista/datasets/master/COVID%2019/ccaa_covid19_fallecidos.csv") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
❤️