diff --git a/scripts/data_prep/raw_to_prepared.R b/scripts/data_prep/raw_to_prepared.R index 76545f0..7e196f4 100644 --- a/scripts/data_prep/raw_to_prepared.R +++ b/scripts/data_prep/raw_to_prepared.R @@ -14,6 +14,7 @@ library(readxl) folderIn <- "Data/dl/" folderOut <- "Data/prepData/" +sig_figs = 6 APIKey <- Sys.getenv("API_KEY") dir.create("Data/prepData/") options(timeout=600, error = traceback) @@ -347,6 +348,7 @@ dVariance <- data.frame(ref = c("shape_inter","shape_coef1","shape_coef2","shape dMean <- data.frame(F1 = unname(fitF1$coefficients),F2 = unname(fitF2$coefficients),F3 = unname(fitF3$coefficients),F4 = unname(fitF4$coefficients), M1 = unname(fitM1$coefficients),M2 = unname(fitM2$coefficients),M3 = unname(fitM3$coefficients),M4 = unname(fitM4$coefficients) ) +dMean <- dMean %>% mutate_all(function(x) signif(x, sig_figs)) print("Writing outputs...") write.table(dMean,paste(folderOut,"BMIdMean.csv",sep = ""),row.names = F, sep = ",") diff --git a/scripts/data_prep/raw_to_prepared_Income.R b/scripts/data_prep/raw_to_prepared_Income.R index d88513e..66c3329 100644 --- a/scripts/data_prep/raw_to_prepared_Income.R +++ b/scripts/data_prep/raw_to_prepared_Income.R @@ -1,6 +1,7 @@ library(parallel) library(readxl) +sig_figs = 6 folderIn <- "Data/dl/" folderOut <- "Data/prepData/" options(timeout=600) @@ -198,13 +199,13 @@ coefTable <- function(table,t){ # t = max allowed p-value for fitting } print("Calculating coefficients for Female Full-Time") -coefFFT <- coefTable(refFFT,0.01) +coefFFT <- coefTable(refFFT,0.01) %>% mutate_at(vars(inter,coef1,coef2,coef3,ceilingVal), function(x) signif(s, sig_figs)) print("Calculating coefficients for Female Part-Time") -coefFPT <- coefTable(refFPT,0.01) +coefFPT <- coefTable(refFPT,0.01) %>% mutate_at(vars(inter,coef1,coef2,coef3,ceilingVal), function(x) signif(s, sig_figs)) print("Calculating coefficients for Male Full-Time") -coefMFT <- coefTable(refMFT,0.01) +coefMFT <- coefTable(refMFT,0.01) %>% mutate_at(vars(inter,coef1,coef2,coef3,ceilingVal), function(x) signif(s, sig_figs)) print("Calculating coefficients for Male Part-Time") -coefMPT <- coefTable(refMPT,0.01) +coefMPT <- coefTable(refMPT,0.01) %>% mutate_at(vars(inter,coef1,coef2,coef3,ceilingVal), function(x) signif(s, sig_figs)) print("Writing modelled coefficients") write.table(coefFFT,paste(folderOut,"coefFFT.csv",sep = ""),row.names = F,sep = ",") @@ -807,9 +808,9 @@ meanHoursFFT$mean <- as.numeric(meanHoursFFT$mean) meanHoursFPT <- resFPT[[2]] meanHoursFPT$mean <- as.numeric(meanHoursFPT$mean) -distribHours = data.frame(MFT = distribHoursMFT, MPT = distribHoursMPT, +distribHours <- data.frame(MFT = distribHoursMFT, MPT = distribHoursMPT, FFT = distribHoursFFT, FPT = distribHoursFPT) - +distribHours <- distribHours %>% mutate_all(function(x) signif(x, sig_figs)) print("Writing outputs...") write.table(distribHours,paste(folderOut,"distribHours.csv",sep = ""),row.names = F,sep = ",") diff --git a/scripts/data_prep/renv.lock b/scripts/data_prep/renv.lock index 7afc26b..33b272c 100644 --- a/scripts/data_prep/renv.lock +++ b/scripts/data_prep/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "4.3.1", + "Version": "4.3.2", "Repositories": [ { "Name": "CRAN", @@ -763,6 +763,25 @@ ], "Hash": "7e5e3cbd2a7bc07880c94e22348fb661" }, + "httr2": { + "Package": "httr2", + "Version": "0.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "cli", + "curl", + "glue", + "magrittr", + "openssl", + "rappdirs", + "rlang", + "withr" + ], + "Hash": "193bb297368afbbb42dc85784a46b36e" + }, "ids": { "Package": "ids", "Version": "1.0.1", @@ -1199,7 +1218,12 @@ "renv": { "Package": "renv", "Version": "1.0.3", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "utils" + ], + "Hash": "41b847654f567341725473431dd0d5ab" }, "reprex": { "Package": "reprex",