Skip to content

Commit

Permalink
based on formr pre haven semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenarslan committed Nov 3, 2017
1 parent 8afc30a commit 1373a10
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^docs
.zenodo.json
11 changes: 11 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"title": "Cook codebooks from survey metadata encoded in attributes in R",
"upload_type": "software",
"creators": [
{
"affiliation": "Center for Adaptive Rationality, Max Planck Institute for Human Development",
"name": "Ruben C. Arslan"
}
],
"access_right": "open"
}
3 changes: 2 additions & 1 deletion R/codebook.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ codebook = function(results, indent = '#') {
#' @param scale a scale with attributes set
#' @param results a formr results table with attributes set on items and scales
#' @param indent add # to this to make the headings in the components lower-level. defaults to beginning at h2
#' @param survey_repetition defaults to single (other values: repeated_once, repeated_many). controls whether internal consistency, retest reliability or multilevel reliability is computed
#'
#' @export
codebook_component_scale = function(scale, results, indent = '###') {
codebook_component_scale = function(scale, results, indent = '###', survey_repetition = "single") {
stopifnot( exists("item", attributes(scale)))
stopifnot( exists("scale", attributes(scale)))
stopifnot( exists("scale_item_names", attributes(scale)))
Expand Down
4 changes: 2 additions & 2 deletions inst/_codebook.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ ggplot2::qplot(duration$duration, binwidth = 0.5) + ggplot2::scale_x_continuous(

```{r scales,results='asis'}
vars = names(results)
knit_scales = listenv::listenv()
knit_scales = new.env()
for (i in seq_along(vars)) {
var = vars[i]
scale = results[[ var ]]
scale_info = attributes(scale)
if ( !is.null(scale_info)) {
if (exists("scale", scale_info)) {
knit_scales[[ var ]] = future::value(future::future( codebook_component_scale( scale, results, indent ) ))
future::`%<-%`(knit_scales[[ var ]], codebook_component_scale( scale, dplyr::select(results, session, dplyr::starts_with(scale_info$scale)), indent, survey_repetition) )
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion man/codebook_component_scale.Rd

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

0 comments on commit 1373a10

Please sign in to comment.