Skip to content

Commit

Permalink
quash NOTEs
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenarslan committed Oct 13, 2024
1 parent e9ea7de commit 046a01d
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ revdep
renv.lock
^renv\.lock$
figure
.github
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ export(zap_label)
export(zap_labelled)
importFrom(dplyr,"%>%")
importFrom(forcats,as_factor)
importFrom(graphics,plot)
importFrom(haven,zap_label)
importFrom(labelled,"val_label<-")
importFrom(labelled,"val_labels<-")
importFrom(labelled,"var_label<-")
importFrom(labelled,val_label)
importFrom(labelled,val_labels)
importFrom(labelled,var_label)
importFrom(rlang,.data)
importFrom(vctrs,vec_data)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# codebook 0.9.5
## Changes
- default to psych for reliability because rosetta/ufs is hard to install
- no longer depends on archived package userfriendlyscience
## Bugfixes
- compatibility with glue 1.8.0

Expand Down
5 changes: 4 additions & 1 deletion R/codebook.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#' @importFrom rlang .data
.data <- rlang::.data

no_md <- function() {
Expand Down Expand Up @@ -26,6 +27,7 @@ no_md <- function() {
#' @param metadata_json whether to include machine-readable metadata as JSON-LD (not visible)
#' @param indent add # to this to make the headings in the components lower-level. defaults to beginning at h2
#'
#' @importFrom graphics plot
#' @export
#' @examples
#' # will generate figures in a temporary directory
Expand Down Expand Up @@ -327,7 +329,8 @@ codebook_missingness <- function(results, indent = "##") {
#' data("bfi")
#' metadata_jsonld(bfi)
metadata_jsonld <- function(results) {
jsonld_metadata <- metadata_list(results)
jsonld_metadata <- jsonlite::toJSON(metadata_list(results),
pretty = TRUE, auto_unbox = TRUE)
rmdpartials::partial(require_file("inst/_metadata_jsonld.Rmd"),
name = "metadata_", render_preview = FALSE)
}
Expand Down
1 change: 1 addition & 0 deletions R/codebook_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ attribute_summary <- function(var) {
#' because the underlying data can be numeric or character. This skimmers summarises
#' both and leaves non-pertinent columns missings.
#'
#' @importFrom vctrs vec_data
#' @param column the column to skim
#'
#' @exportS3Method skimr::get_skimmers haven_labelled
Expand Down
4 changes: 2 additions & 2 deletions R/detect_scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#' @export
#'
#' @examples
#' bfi <- data.frame(matrix(data = rnorm(500), ncol = 5))
#' names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3", "bfi_n1", "bfi_n2")
#' bfi <- data.frame(matrix(data = rnorm(300), ncol = 3))
#' names(bfi) <- c("bfi_e1", "bfi_e2R", "bfi_e3")
#' bfi$bfi_e <- rowMeans(bfi[, c("bfi_e1", "bfi_e2R", "bfi_e3")])
#' bfi <- detect_scales(bfi)
#' bfi$bfi_e
Expand Down
9 changes: 3 additions & 6 deletions R/reliability.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
#'
#' @export
#' @examples
#' \dontrun{
#' data("bfi", package = "codebook")
#' bfi <- bfi %>% dplyr::select(dplyr::starts_with("BFIK_agree"))
#' reliabilities <- compute_reliabilities(bfi)
#' }

compute_reliabilities <- function(results, survey_repetition = "single",
use_psych = TRUE) {
Expand Down Expand Up @@ -109,10 +107,9 @@ compute_appropriate_reliability <- function(scale_name, scale_info,
"rows need to reflect the earlier measurement occasion, so that ",
"retest statistics can be computed")
}

t1_items <- results[!duplicated(results$session),
t1_items <- results[!duplicated(results[, id_vars]),
scale_item_names, drop = FALSE]
t2_items <- results[duplicated(results$session),
t2_items <- results[duplicated(results[, id_vars]),
scale_item_names, drop = FALSE]

list(
Expand All @@ -137,7 +134,7 @@ compute_appropriate_reliability <- function(scale_name, scale_info,
long_rel <- tidyr::gather(dplyr::select(dplyr::mutate(
dplyr::group_by(results, .data$session),
day_number = as.numeric(.data$created - min(.data$created), unit = 'days')
), session, .data$day_number,
), .data$session, .data$day_number,
!!!scale_item_names ),
"variable", "value", -"session", -"day_number")

Expand Down
4 changes: 3 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## Submission
* Compatibility with glue 1.8.0
* Reduced dependencies
* no longer suggests archived package userfriendlyscience
* there are still many dependencies, but these are mainly tidyverse packages, so depending on one, there is little additional cost to depend also on others
* there are other dependencies I hope to be able to remove soon (e.g., vctrs is only used in testing and for one edge case that a bugfix in haven can eliminate)
* Updated citation to published paper
* one declared import (graphics) is used only in one of the rmarkdown partials
- inst/codebook_scale.Rmd, line 38
* Unfortunately, I have had to wrap some examples using the codebook function in dontrun, because I haven't yet figured out how to make rmdpartials switch to "interactive" mode when testing/checking. Once I fix this problem in rmdpartials, I will remove dontrun
* I also had to wrap the example for `compute_reliabilities` in dontrun, because even a minimal example sometimes takes longer than 10s. I considered using donttest instead, but according to what I could find online donttest is also tested & timed.

## Test environments
* local OS X install, R 4.4.1
Expand Down
9 changes: 4 additions & 5 deletions inst/_metadata_jsonld.Rmd
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
```{r setup,eval=TRUE,echo=FALSE}
if (exists("testing")) {
indent = '#' # ugly hack so _regression_summary can be "spun" (variables included via `r ` have to be available)
indent = '#' # ugly hack so _metadata_jsonld.Rmd can be "spun" (variables included via `r ` have to be available)
results = data.frame()
jsonld_metadata <- list(test = 1)
jsonld_metadata <- jsonlite::toJSON(list(test = 1), pretty = TRUE, auto_unbox = TRUE)
}
json <- jsonlite::toJSON(jsonld_metadata, pretty = TRUE, auto_unbox = TRUE)
```

<script type="application/ld+json">
`r json`
`r jsonld_metadata`
</script>

<details><summary>JSON-LD metadata</summary>
The following JSON-LD can be found by search engines, if you share this codebook
publicly on the web.

```json
`r json``
`r jsonld_metadata``
```
</details>
2 changes: 0 additions & 2 deletions man/compute_reliabilities.Rd

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

4 changes: 2 additions & 2 deletions man/detect_scales.Rd

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

0 comments on commit 046a01d

Please sign in to comment.