Skip to content

Commit

Permalink
Update with signif for deterministic output
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreenbury committed Nov 9, 2023
1 parent a7b729f commit 8ad4500
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions scripts/data_prep/raw_to_prepared.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = ",")
Expand Down
13 changes: 7 additions & 6 deletions scripts/data_prep/raw_to_prepared_Income.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library(parallel)
library(readxl)

sig_figs = 6
folderIn <- "Data/dl/"
folderOut <- "Data/prepData/"
options(timeout=600)
Expand Down Expand Up @@ -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 = ",")
Expand Down Expand Up @@ -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 = ",")

Expand Down
28 changes: 26 additions & 2 deletions scripts/data_prep/renv.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"R": {
"Version": "4.3.1",
"Version": "4.3.2",
"Repositories": [
{
"Name": "CRAN",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1199,7 +1218,12 @@
"renv": {
"Package": "renv",
"Version": "1.0.3",
"Source": "Repository"
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"utils"
],
"Hash": "41b847654f567341725473431dd0d5ab"
},
"reprex": {
"Package": "reprex",
Expand Down

0 comments on commit 8ad4500

Please sign in to comment.