knitr::opts_chunk$set(echo = TRUE) knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # knitr::opts_knit$get("root.dir") # alternative to the previous line # the default autosave location will depend on this being setup options(warn=-1)
knitr::opts_chunk$set(echo = TRUE) library(FPEMlocal) devtools::load_all() div <- 356 # name <- "Bihar" # path1 <- "C:/Users/desktop-g/Downloads/Bihar_Survey071420.csv" # path2 <- "C:/Users/desktop-g/Downloads/Bihar_Pop.csv" name <- "UttaPradesh" path1 <- "C:/Users/desktop-g/Downloads/UttarPradesh_Survey071420.csv" path2 <- "C:/Users/desktop-g/Downloads/UttarPradesh_Pop.csv" # changing names since avenir does not use the same format as us # temp <- read.csv(path1) # temp <- temp %>% dplyr::rename(division_numeric_code = unit_numeric_code) # write.csv(temp, path1) # temp <- read.csv(path2) # temp <- temp %>% dplyr::rename(division_numeric_code = unit_numeric_code) # write.csv(temp, path2)
fit <- fit_fp_c( surveydata_filepath = path1, population_data = read.csv(path2), division_numeric_code = div, is_in_union = "ALL", first_year = 1970, last_year = 2030, subnational = TRUE )
results <- calc_fp_c(fit = fit, population_data = read.csv(path2))
newreslist <- list() unions <- c("Y", "N", "ALL") for (i in 1:3) { is_in_union <- unions[i] res <- results[[is_in_union]] newreslist[[i]] <- data.frame( name_subregion = name, division_numeric_code = div, is_in_union = is_in_union, year = res$contraceptive_use_any$year, percentile = res$contraceptive_use_any$percentile, contraceptive_use_any = res$contraceptive_use_any$value, contraceptive_use_modern = res$contraceptive_use_modern$value, contraceptive_use_traditional = res$contraceptive_use_traditional$value, unmet_need_any = res$unmet_need_any$value, unmet_need_modern = res$unmet_need_modern$value, demand_satisfied_modern = res$demand_satisfied_modern$value ) } # rbind across the list df <- do.call(rbind, newreslist) write.csv(df, paste0(name, "_results.csv"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.