我有一个名为ind_prov
的列表,其结构如下:
我想要这样一个data.frame,但是要有22个元素:
> provincias <-
+ ind_prov[[list_vars[1]]] %>%
+ left_join(ind_prov[[list_vars[2]]],
+ by = c("fecha", "provincia")) %>%
+ left_join(ind_prov[[list_vars[3]]],
+ by = c("fecha", "provincia"))
> provincias
# A tibble: 2,086 x 5
fecha provincia emp_pob ofc_pob caje_pob
<date> <chr> <dbl> <dbl> <dbl>
1 2013-03-01 Monte Cristi 0.000184 0.0000117 0.0000235
2 2013-03-01 San Pedro de Macorís 0.00413 0.0000869 0.000799
3 2013-03-01 San Pedro de Macorís 0.00413 0.000191 0.000799
4 2013-03-01 El Seibo 0.000152 0.00000338 0.0000236
5 2013-03-01 El Seibo 0.000152 0.0000101 0.0000236
6 2013-03-01 Hato Mayor 0.000339 0.00000595 0.0000535
7 2013-03-01 Hato Mayor 0.000339 0.0000297 0.0000535
8 2013-03-01 Monte Plata 0.0000215 0.00000117 0.00000430
9 2013-03-01 Monte Plata 0.0000215 0.000000782 0.00000430
10 2013-03-01 Azua 0.000634 0.0000474 0.0000533
# ... with 2,076 more rows
我不想这样做:
provincias <-
ind_prov[[list_vars[1]]] %>%
left_join(ind_prov[[list_vars[2]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[3]]],
by = c("fecha", "provincia"))
left_join(ind_prov[[list_vars[4]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[5]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[6]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[7]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[8]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[9]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[10]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[11]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[12]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[13]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[14]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[15]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[16]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[17]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[18]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[19]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[20]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[21]]],
by = c("fecha", "provincia")) %>%
left_join(ind_prov[[list_vars[22]]],
by = c("fecha", "provincia"))