-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c09ed84
commit 3f17e85
Showing
10 changed files
with
269 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# WARNING - Generated by {fusen} from /dev/flat_r6_questionnaire.Rmd: do not edit by hand | ||
|
||
#' questionnaire class is a class to load, check and manipulate one or more than one XLSForm | ||
#' @importFrom R6 R6Class | ||
#' | ||
#' @export | ||
|
||
questionnaire <- R6::R6Class(classname = "questionnaire", | ||
public = list( | ||
#' @description | ||
#' read the xlsx for each sheet and return a named list | ||
#' @param path path to the xlsForm | ||
#' | ||
#' @importFrom readxl excel_sheets read_xlsx | ||
#' @importFrom stats setNames | ||
#' | ||
#' @return named list | ||
#' @examples | ||
#' ref <- questionnaire$new( | ||
#' path = system.file("household_survey_americas.xlsx", package = "surveyDesigner") | ||
#' ) | ||
#' | ||
#' head(ref$data$survey) | ||
#' | ||
#' # Example by groups | ||
#' ref$by_groups$group_intro | ||
initialize = function(path){ | ||
# Define path | ||
self$path <- path | ||
|
||
# Get sheets of xlsx | ||
sheets <- names_of_sheet(path) | ||
|
||
# Read the xlsx file | ||
data <- lapply( | ||
sheets, | ||
function(x){ | ||
read_xlsx(path = path, sheet = x)}) |> | ||
setNames(nm = sheets) | ||
# TODO checking survey and other sheets | ||
} | ||
), | ||
private = list( | ||
|
||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# WARNING - Generated by {fusen} from /dev/flat_r6_referential.Rmd: do not edit by hand | ||
|
||
test_that("utils_indicator_map works", { | ||
expect_true(inherits(has_variables_for_indicators, "function")) | ||
|
||
expect_true(inherits(indicator_linked_population, "function")) | ||
|
||
expect_true(inherits(population_linked_indicator, "function")) | ||
|
||
expect_true(inherits(indicator_linked_variable, "function")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# WARNING - Generated by {fusen} from /dev/flat_r6_referential.Rmd: do not edit by hand | ||
|
||
test_that("utils_xlsform works", { | ||
|
||
expect_true(inherits(get_groups, "function")) | ||
|
||
ref <- Referential$new( | ||
path = system.file("SurveyDesigner_Referential.xlsx", package = "surveyDesigner") | ||
) | ||
result <- get_groups(ref$data$survey) | ||
expect_named(result[[1]], c("data", "information")) | ||
expect_type(result, "list") | ||
|
||
|
||
expect_true(inherits(get_choices_for_question, "function")) | ||
get_choices <- get_choices_for_question(ref$data$choices, "pop_groups") | ||
|
||
expect_type(get_choices, "list") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# WARNING - Generated by {fusen} from /dev/flat_r6_questionnaire.Rmd: do not edit by hand | ||
|
||
test_that("r6_questionnaire works", { | ||
ref <- questionnaire$new( | ||
path = system.file("household_survey_americas.xlsx", package = "surveyDesigner") | ||
) | ||
|
||
expect_true( inherits(ref, "R6") ) | ||
|
||
expect_error( | ||
questionnaire$new( | ||
path = "not_good_sheet.xlsx" | ||
) | ||
) | ||
|
||
expect_error( | ||
questionnaire$new( | ||
path = "wt_xlsform_in_survey.xlsx" | ||
) | ||
) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# WARNING - Generated by {fusen} from /dev/flat_r6_questionnaire.Rmd: do not edit by hand | ||
|
||
test_that("utils_questionnaire works", { | ||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Class R6 for the questionnaire" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{class-r6-for-the-questionnaire} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(surveyDesigner) | ||
``` | ||
|
||
<!-- WARNING - This vignette is generated by {fusen} from /dev/flat_r6_questionnaire.Rmd: do not edit by hand --> | ||
|
||
# r6_Questionnaire | ||
|
||
A questionnaire is created as a list that includes: | ||
* a summary of the annual survey cycle for a specific context | ||
* one or multiple [XlsForm](http://xlsform.org) that will be then used to collect information. | ||
|
||
A questionnaire object is created out of two objects: | ||
* a global referential | ||
* a specific context | ||
|
||
|
||
|
||
|
||
```{r examples-r6_questionnaire} | ||
ref <- questionnaire$new( | ||
path = system.file("household_survey_americas.xlsx", package = "surveyDesigner") | ||
) | ||
head(ref$data$survey) | ||
# Example by groups | ||
ref$by_groups$group_intro | ||
``` | ||
|
||
# Utils for questionnaire | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters