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

Commit

Permalink
fix issues for CRAN Registration...
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard-Legoupil committed Jul 16, 2019
1 parent 978cc66 commit 1c39373
Show file tree
Hide file tree
Showing 143 changed files with 2,299 additions and 3,944 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
^\.Rproj\.user$
^\.Rprofile$
^appveyor\.yml$
^codecov\.yml$
^\.travis\.yml$
^cran-comments\.md$
^_config\.yml$
Expand Down
76 changes: 48 additions & 28 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: koboloadeR
Type: Package
Title: A metapackage for Survey Data Crunching
Version: 0.1.6
Authors@R: c(person("Edouard", "Legoupil", role = c("aut", "cre"), email = "legoupil@unhcr.org"),
Authors@R: c(person("Edouard", "Legoupil", role = c("aut", "cre"), email = "edouard.legoupil@gmail.com"),
person("Maher", "Daoud", role = "aut", email = "daoudma@unhcr.org"),
person("Elliott", "Messeiller", role = "ctb", email = "elliott.messeiller@acted.org"),
person("Damien", "Seite", role = "ctb", email = "damien.seite@eleve.ensai.fr"))
Expand All @@ -11,47 +11,67 @@ Description: This package facilitates the data crunching & exploration for datas
License: GPL-3
LazyData: TRUE
Depends:
utils,
data.table (>= 1.9.4),
curl,
RCurl,
httr,
bit64,
readr,
utils
Imports:
ggplot2,
DDIwR,
DT,
plyr,
dplyr,
tidyr,
glue,
ggthemes,
ggrepel,
httr,
haven,
OpenRepGrid,
plyr,
RCurl,
readxl,
ggplot2,
reshape2,
digest,
sdcMicro,
readr,
rJava,
xlsx,
haven,
RODBC,
rstudioapi,
shiny,
shinydashboard,
shinyalert,
ape,
sp,
gdata,
rhandsontable,
survey,
stringr,
stringi,
sp,
simFrame,
classInt,
ggrepel,
DDIwR,
sdcMicro,
truncnorm,
OpenRepGrid
xlsx,
tidyr
Suggests:
shiny,
ape,
bit64,
classInt,
curl,
car,
corrplot,
data.table,
digest,
dplyr,
forcats,
graphics,
gridExtra,
hexbin,
kableExtra,
knitr,
koRpus,
lubridate,
rmarkdown,
RColorBrewer,
rhandsontable,
scales,
tables,
vcd,
viridis,
testthat (>= 2.1.0),
utils,
knitr
zoo
URL: https://github.com/unhcr/koboloadeR/docs
BugReports: https://github.com/unhcr/koboloadeR/issues
RoxygenNote: 6.1.1
VignetteBuilder: utils
VignetteBuilder: knitr
Encoding: UTF-8
SystemRequirements: Java (>= 8)
25 changes: 1 addition & 24 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@ export(kobo_anonymise)
export(kobo_apps)
export(kobo_arrange_variablename)
export(kobo_atlas_report)
export(kobo_bar_multi)
export(kobo_bar_multi_facet)
export(kobo_bar_multi_print)
export(kobo_bar_one)
export(kobo_bar_one_facet)
export(kobo_bar_one_facet_print)
export(kobo_bar_one_print)
export(kobo_boxplot_facet)
export(kobo_check_analysis_plan)
export(kobo_check_project_configuration)
export(kobo_clean)
export(kobo_cluster_report)
export(kobo_consolidateone)
export(kobo_correlation)
export(kobo_correlation_analysis)
export(kobo_check_project_configuration)
export(kobo_corrplot)
export(kobo_create_indicators)
export(kobo_crunching_report)
export(kobo_data_downloader)
Expand All @@ -40,8 +30,6 @@ export(kobo_get_begin_repeat)
export(kobo_get_config)
export(kobo_get_dataframes_levels)
export(kobo_get_theme)
export(kobo_histo)
export(kobo_histo_print)
export(kobo_indicator)
export(kobo_label)
export(kobo_left_align)
Expand All @@ -60,13 +48,8 @@ export(kobo_samplingframe)
export(kobo_shiny)
export(kobo_split_multiple)
export(kobo_submission_count)
export(kobo_surveyname)
export(kobo_text_cloud)
export(kobo_time_parser)
export(kobo_time_parser_UTC)
export(kobo_to_xlsform)
export(kobo_trend)
export(kobo_trend_report)
export(kobo_unhcr_style_bar)
export(kobo_unhcr_style_histo)
export(kobo_unhcr_style_map)
Expand All @@ -76,13 +59,7 @@ export(ltbl)
export(multresponse)
export(psum)
export(round2)
import(DT)
import(RCurl)
import(bit64)
import(data.table)
import(dplyr)
import(httr)
import(plyr)
import(readr)
import(readxl)
import(tidyr)
26 changes: 13 additions & 13 deletions R/kobo_anonymisation_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#'
#'

kobo_anonymisation_report <- function(frame, form = "form.xls", app="console") {
kobo_anonymisation_report <- function(frame, form = "form.xls", app = "console") {
tryCatch({
if(app=="shiny"){
if (app == "shiny") {
progress <- shiny::Progress$new()
progress$set(message = "Generating crunching report in progress...", value = 0)
on.exit(progress$close())
Expand All @@ -40,9 +40,9 @@ kobo_anonymisation_report <- function(frame, form = "form.xls", app="console") {
mainDir <- kobo_getMainDirectory()
form_tmp <- paste(mainDir, "data", form, sep = "/", collapse = "/")

dico <- read.csv(paste0(mainDir,"/data/dico_",form,".csv"), encoding = "UTF-8", na.strings = "")
dico <- utils::read.csv(paste0(mainDir,"/data/dico_",form,".csv"), encoding = "UTF-8", na.strings = "")
framename <- deparse(substitute(frame))
write.csv(frame, paste0(mainDir,"/data/anomreport-",framename,".csv"), row.names = FALSE, na = "")
utils::write.csv(frame, paste0(mainDir,"/data/anomreport-",framename,".csv"), row.names = FALSE, na = "")

## Check that all those selectedVars are in the frame ####
check <- as.data.frame(names(frame))
Expand All @@ -51,24 +51,24 @@ kobo_anonymisation_report <- function(frame, form = "form.xls", app="console") {


#### Check presence of variable for anom plan...
if(app=="shiny"){
if (app == "shiny") {
progress$set(message = "Check presence of variable for anom plan...")
updateProgress()
}
selected.key <- dico[ which(dico$anonymise == "key" & dico$type == "select_one" ) , ]
selected.key <- join(x = selected.key, y = check, by = "fullname", type = "left")
selected.key <- plyr::join(x = selected.key, y = check, by = "fullname", type = "left")
selected.key <- selected.key[!is.na(selected.key$id), ]

if ( nrow(selected.key) == 0) {
cat("You have not selected key variables for your dataset! \n")
return(structure("You have not selected key variables for your dataset!", class = "try-error"))
} else {
selected.sensible <- dico[ which(dico$anonymise == "sensitive" & dico$type == "select_one" ), ]
selected.sensible <- join(x = selected.sensible, y = check, by = "fullname", type = "left")
selected.sensible <- plyr::join(x = selected.sensible, y = check, by = "fullname", type = "left")
selected.sensible <- selected.sensible[!is.na(selected.sensible$id), ]

selected.num <- dico[ which(dico$anonymise == "outlier" ), ]
selected.num <- join(x = selected.num, y = check, by = "fullname", type = "left")
selected.num <- plyr::join(x = selected.num, y = check, by = "fullname", type = "left")
selected.num <- selected.num[!is.na(selected.num$id), ]


Expand Down Expand Up @@ -113,10 +113,10 @@ kobo_anonymisation_report <- function(frame, form = "form.xls", app="console") {
cat("## Provide below the name of the form in xsl form - format should be xls not xlsx", file = reportanom , sep = "\n", append = TRUE)
cat("form <- \"form.xls\"", file = reportanom , sep = "\n", append = TRUE)
#cat("kobo_dico(form)", file = reportanom , sep = "\n", append = TRUE)
cat("dico <- read.csv(paste0(mainDirroot,\"/data/dico_\",form,\".csv\"), encoding = \"UTF-8\", na.strings = \"\")", file = reportanom , sep = "\n", append = TRUE)
cat("dico <- utils::read.csv(paste0(mainDirroot,\"/data/dico_\",form,\".csv\"), encoding = \"UTF-8\", na.strings = \"\")", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)

cat(paste0("dataanom <- read.csv(paste0(mainDirroot,\"/data/anomreport-",framename,".csv\"), sep = \",\", encoding = \"UTF-8\", na.strings = \"\")"), file = reportanom , sep = "\n", append = TRUE)
cat(paste0("dataanom <- utils::read.csv(paste0(mainDirroot,\"/data/anomreport-",framename,".csv\"), sep = \",\", encoding = \"UTF-8\", na.strings = \"\")"), file = reportanom , sep = "\n", append = TRUE)


# cat(paste0("dataanom <- read.csv(paste0(mainDirroot,\"/data/anomreport-",framename,".csv\") , sep = \";\", encoding = \"UTF-8\", na.strings = \"\")", file = reportanom , sep = "\n", append = TRUE))
Expand All @@ -134,16 +134,16 @@ kobo_anonymisation_report <- function(frame, form = "form.xls", app="console") {
cat("\n", file = reportanom , sep = "\n", append = TRUE)
cat(" #### Remove ###############", file = reportanom , sep = "\n", append = TRUE)
cat("selected.key <- dico[ which(dico$anonymise == \"key\" & dico$type == \"select_one\" ) , ]", file = reportanom , sep = "\n", append = TRUE)
cat("selected.key <- join(x = selected.key, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.key <- plyr::join(x = selected.key, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.key <- selected.key[!is.na(selected.key$id), ]", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)
cat("selected.sensible <- dico[ which(dico$anonymise == \"sensitive\" & dico$type == \"select_one\" ), ]", file = reportanom , sep = "\n", append = TRUE)
cat("selected.sensible <- join(x = selected.sensible, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.sensible <- plyr::join(x = selected.sensible, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.sensible <- selected.sensible[!is.na(selected.sensible$id), ]", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)
cat("selected.num <- dico[ which(dico$anonymise == \"outlier\" ), ]", file = reportanom , sep = "\n", append = TRUE)
cat("selected.num <- join(x = selected.num, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.num <- plyr::join(x = selected.num, y = check, by = \"fullname\", type = \"left\")", file = reportanom , sep = "\n", append = TRUE)
cat("selected.num <- selected.num[!is.na(selected.num$id), ]", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)
cat("\n", file = reportanom , sep = "\n", append = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/kobo_anonymise.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' }
#'
#'
#' @param kobo or odk dataset to use
#' @param frame dataset to use
#' @param dico Generated from kobo_dico function
#'
#' @author Edouard Legoupil
Expand Down
4 changes: 2 additions & 2 deletions R/kobo_atlas_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#'
#'
#'
#' @param kobo or odk dataset to use
#' @param frame odk dataset to use
#' @param dico Generated from kobo_dico function
#' @param map equaly mappoly or mappoint depending on the type of visualisation expected - polygons or points
#' @param mappoly or mappoint depending on the type of visualisation expected - polygons or points
#'
#' @author Edouard Legoupil
#'
Expand Down
Loading

0 comments on commit 1c39373

Please sign in to comment.