Convert a dataset retrieved with fetch_indicator()
to DCS format.
format_dcs(df, type = c("data", "meta"))
data.frame: A pddcs
formatted data frame. Output of
fetch_indicator()
.
character: Type, either 'data' or 'meta'.
tibble
# Load example data
data("bednets")
# Convert to 'data' format
format_dcs(bednets, type = "data")
#> # A tibble: 239 × 5
#> Time Country Series Scale Data
#> <chr> <chr> <chr> <dbl> <dbl>
#> 1 YR2015 AFG SH.MLR.NETS.ZS 0 4.6
#> 2 YR2007 AGO SH.MLR.NETS.ZS 0 18
#> 3 YR2011 AGO SH.MLR.NETS.ZS 0 25.9
#> 4 YR2016 AGO SH.MLR.NETS.ZS 0 21.7
#> 5 YR2000 AZE SH.MLR.NETS.ZS 0 1
#> 6 YR2000 BDI SH.MLR.NETS.ZS 0 1
#> 7 YR2005 BDI SH.MLR.NETS.ZS 0 8
#> 8 YR2010 BDI SH.MLR.NETS.ZS 0 45.3
#> 9 YR2012 BDI SH.MLR.NETS.ZS 0 53.8
#> 10 YR2016 BDI SH.MLR.NETS.ZS 0 39.9
#> # … with 229 more rows
# Convert to 'metadata' format
format_dcs(bednets, type = "meta")
#> # A tibble: 239 × 4
#> Country Series Time Footnote
#> <chr> <chr> <chr> <chr>
#> 1 AFG SH.MLR.NETS.ZS YR2015 Demographic and Health Survey 2015
#> 2 AGO SH.MLR.NETS.ZS YR2007 Other National Survey 2006-2007
#> 3 AGO SH.MLR.NETS.ZS YR2011 Malaria Indicator Survey 2011
#> 4 AGO SH.MLR.NETS.ZS YR2016 Demographic and Health Survey 2015-2016
#> 5 AZE SH.MLR.NETS.ZS YR2000 Multiple Indicator Cluster Survey 2000
#> 6 BDI SH.MLR.NETS.ZS YR2000 Multiple Indicator Cluster Survey 2000
#> 7 BDI SH.MLR.NETS.ZS YR2005 Multiple Indicator Cluster Survey 2005
#> 8 BDI SH.MLR.NETS.ZS YR2010 Demographic and Health Survey 2010
#> 9 BDI SH.MLR.NETS.ZS YR2012 Malaria Indicator Survey 2012
#> 10 BDI SH.MLR.NETS.ZS YR2016 Demographic and Health Survey 2016
#> # … with 229 more rows