Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

rev doc #71

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revise doc
  • Loading branch information
Edouard-Legoupil committed Nov 16, 2020
commit 829ff7c20b4e5e34b0bce6386c2b8e309c6088b0
41 changes: 24 additions & 17 deletions R/kobo_crunching_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 725,10 @@ kobo_crunching_report <- function(form = "form.xlsx",
# v <- 3
chaptersname <- as.character(chapters[ v , 1])

report.name.i.v <-
report.name.i.v <-
stringr::str_c(
report.name,
stringr::str_pad(i, 2, pad = "0"),
report.name,
stringr::str_pad(i, 2, pad = "0"),
stringr::str_pad(v, 2, pad = "0"),
"00",
sep = "-")
Expand Down Expand Up @@ -759,17 759,17 @@ kobo_crunching_report <- function(form = "form.xlsx",
progress$set(message = "Getting levels for each questions in progress...")
updateProgress()
}

crunch_question <- function(j)
{
report.name.i.v.j <-
report.name.i.v.j <-
stringr::str_c(
report.name,
stringr::str_pad(i, 2, pad = "0"),
report.name,
stringr::str_pad(i, 2, pad = "0"),
stringr::str_pad(v, 2, pad = "0"),
stringr::str_pad(j, 2, pad = "0"),
sep = "-")

## Now getting level for each questions
if (app == "shiny") {
progress$set(message = paste("Render question: ",as.character(chapterquestions[ j , c("labelReport")])))
Expand Down Expand Up @@ -2183,16 2183,16 @@ kobo_crunching_report <- function(form = "form.xlsx",

## End loop on questions
}

furrr::future_walk(1:nrow(chapterquestions), crunch_question, .progress = FALSE)

if (output == "docx") {
cat(paste("##### Page Break"),file = report.name.i.v ,sep = "\n", append = TRUE)
} else {
cat(paste(""),file = report.name.i.v ,sep = "\n", append = TRUE)
}
}

}


Expand Down Expand Up @@ -2220,17 2220,20 @@ kobo_crunching_report <- function(form = "form.xlsx",
### Render now all reports
cat(" Render now reports... \n")
for (i in 1:nrow(reports)) {
# i <- 1
reportsname <- as.character(reports[ i , 1])

report.name <- paste(mainDir, "/vignettes/",i,"-", reportsname, "-report.Rmd", sep = "")


### Consolidate all report subpart
fs::dir_ls(fs::path_dir(report.name), glob = paste0(report.name, "-*-*")) %>%
purrr::map_chr(readr::read_file) %>%
purrr::walk(readr::write_file, file = report.name, append = TRUE)

fs::dir_ls(fs::path_dir(report.name), glob = paste0(report.name, "-*-*")) %>%
purrr::walk(fs::file_delete)

if (app == "shiny") {
progress$set(message = paste("Rendering output report for ",reportsname, " chapter in progress..."))
updateProgress()
Expand All @@ -2242,7 2245,8 @@ kobo_crunching_report <- function(form = "form.xlsx",
rmarkdown::render(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.Rmd", sep = ""))
## Put the report in the out folder
mainDir <- kobo_getMainDirectory()
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.docx", sep = ""), paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.docx"))
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.docx", sep = ""),
paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.docx"))
## Clean memory
gc()

Expand All @@ -2253,7 2257,8 @@ kobo_crunching_report <- function(form = "form.xlsx",
rmarkdown::render(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.Rmd", sep = ""))
## Put the report in the out folder
mainDir <- kobo_getMainDirectory()
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.html", sep = ""), paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.html"))
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.html", sep = ""),
paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.html"))
## Clean memory
gc()

Expand All @@ -2264,7 2269,8 @@ kobo_crunching_report <- function(form = "form.xlsx",
rmarkdown::render(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.Rmd", sep = ""))
## Put the report in the out folder
mainDir <- kobo_getMainDirectory()
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.html", sep = ""), paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.aspx"))
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.html", sep = ""),
paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.aspx"))
## Clean memory
gc()

Expand All @@ -2275,7 2281,8 @@ kobo_crunching_report <- function(form = "form.xlsx",
rmarkdown::render(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.Rmd", sep = ""))
## Put the report in the out folder
mainDir <- kobo_getMainDirectory()
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.pptx", sep = ""), paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.pptx"))
file.rename(paste(mainDir,"/vignettes/",i,"-", reportsname, "-report.pptx", sep = ""),
paste0(mainDir,"/out/crunching_reports/Crunching-report-",i,"-", reportsname,"-",Sys.Date(), "-report.pptx"))
## Clean memory
gc()
}
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 98,16 @@ Note that the package is still in beta-version. We hope to have soon a release a
* Open R studio interface and within the R console, install `devtools` package:

```{r}
install.packages("devtools")
install.packages("remotes")
```

* Install koboloadeR:

```{r}
devtools::install_github("unhcr/koboloadeR", Ncpus=4)
remotes::install_github("unhcr/koboloadeR", Ncpus=4)

## Use UNHCR graphical template- https://unhcr-web.github.io/unhcRstyle/docs/
remotes::install_github('unhcr-web/unhcRstyle')
```

* You are all set! You can know use koboloadeR. If you have a problem consult the common troubleshooting part at the end of this page.
Expand Down
14 changes: 2 additions & 12 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 12,10 @@ navbar:
menu:
- text: Data Crunching
href: articles/Crunching.html
- text: Steps to build fully reproducible analysis
href: articles/How-to.html
- text: Getting data from server
href: articles/Getting_data.html
- text: Data Analysis Plan within your `xlsfrom`
href: articles/xlsform.html
- text: Using console script
href: articles/Console.html
- text: Sampling
href: articles/Sampling.html
- text: Data Anonymisation and disclosure risk measurement
href: articles/Anonymisation.html
- text: Data Cleaning
href: articles/Cleaning.html
- text: Predicting and scoring
href: articles/Predicting_Scoring.html
- text: Common Troubleshooting
href: articles/Troubleshooting.html
- text: News
Expand Down
19 changes: 2 additions & 17 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/ISSUE_TEMPLATE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/articles/Anonymisation.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/articles/Console.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/articles/Crunching.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions docs/articles/Getting_data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading