Skip to content

Commit d2a4bdd

Browse files
committed
revise documentation of internal functions
1 parent 8a17d42 commit d2a4bdd

10 files changed

Lines changed: 18 additions & 178 deletions

R/getIDVars.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ getIDVars <- function(schema = NULL, input = NULL){
104104
# copy missing values downwards
105105
if(anyNA(temp[1])){
106106
message("filling NA-values in variable '", names(idVars[i]),"'.")
107-
temp <- temp %>%
108-
fill(1, .direction = "down")
107+
temp <- .fill(x = temp, direction = "down", cols = 1)
109108
}
110109

111110
# split ...
@@ -123,8 +122,7 @@ getIDVars <- function(schema = NULL, input = NULL){
123122
}
124123
# fill NAs introduced by non-matching rows after split
125124
if(anyNA(temp[1])){
126-
temp <- temp %>%
127-
fill(1, .direction = "down")
125+
temp <- .fill(x = temp, direction = "down", cols = 1)
128126
}
129127
}
130128

R/helpers.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#' @importFrom dplyr row_number arrange_at
1010
#' @importFrom stringr str_remove_all str_extract_all coll
1111
#' @importFrom tidyselect starts_with
12+
#' @noRd
1213

1314
.updateFormat <- function(input = NULL, schema = NULL){
1415

@@ -152,27 +153,30 @@
152153
#' Convenience wrapper around tidyr::fill()
153154
#'
154155
#' @param x [\code{data.frame(1)}]\cr table in which to fill NA values.
155-
#' @param direction [\code{character(3)}]\cr direction in which to fill missing values,
156-
#' possible values are "down", "up" and "right"; if several directions are
157-
#' required, provide them in the order required.
156+
#' @param direction [\code{character(1)}]\cr direction in which to fill missing
157+
#' values, possible values are "down", "up" and "right".
158+
#' @param cols tidyselect specification of columns to fill; defaults to
159+
#' \code{everything()}. Only honoured for directions "down" and "up"; for
160+
#' "right" all columns are pivoted.
158161
#' @importFrom checkmate assertDataFrame assertCharacter
159162
#' @importFrom tidyr pivot_longer pivot_wider fill
160163
#' @importFrom dplyr group_by everything ungroup
164+
#' @noRd
161165

162-
.fill <- function(x = NULL, direction = TRUE){
166+
.fill <- function(x = NULL, direction = TRUE, cols = everything()){
163167

164168
assertDataFrame(x = x)
165169
assertCharacter(x = direction, len = 1)
166170

167171
if(direction == "down"){
168172

169173
out <- x |>
170-
fill(everything(), .direction = "down")
174+
fill({{ cols }}, .direction = "down")
171175

172176
} else if(direction == "up"){
173177

174178
out <- x |>
175-
fill(everything(), .direction = "up")
179+
fill({{ cols }}, .direction = "up")
176180

177181
} else if(direction == "right"){
178182

@@ -203,6 +207,7 @@
203207
#' @importFrom purrr map
204208
#' @importFrom dplyr left_join pull
205209
#' @importFrom stringr str_c
210+
#' @noRd
206211

207212
.getColTypes <- function(input = NULL, collapse = TRUE){
208213

@@ -244,6 +249,7 @@
244249
#' @importFrom dplyr distinct select bind_cols if_any full_join
245250
#' @importFrom tidyselect all_of everything
246251
#' @importFrom rlang `:=`
252+
#' @noRd
247253

248254
.tidyVars <- function(ids = NULL, obs = NULL, clust = NULL, grp = NULL){
249255

@@ -566,6 +572,7 @@
566572
#' @importFrom dplyr mutate row_number if_else group_by summarise n ungroup
567573
#' left_join pull
568574
#' @importFrom rlang eval_tidy
575+
#' @noRd
569576

570577
.eval_sum <- function(input = NULL, groups = NULL, data = NULL){
571578

@@ -627,6 +634,7 @@
627634
#' @importFrom tidyr pivot_longer pivot_wider
628635
#' @importFrom dplyr select mutate across pull if_else
629636
#' @importFrom stringr str_count str_detect
637+
#' @noRd
630638

631639
.eval_find <- function(input = NULL, col = NULL, row = NULL, clusters = NULL){
632640

@@ -870,6 +878,7 @@
870878
#' the last successful expectation.
871879
#' @importFrom testthat expect_identical
872880
#' @importFrom checkmate expect_names expect_tibble expect_list assertChoice
881+
#' @noRd
873882

874883
.expect_valid_table <- function(x = NULL, units = 1, variables = NULL,
875884
groups = FALSE, flags = FALSE){

_pkgdown.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ reference:
1212
- title: build a schema description
1313
contents:
1414
- schema
15+
- show,schema-method
1516
- schema_builder
1617
- setCluster
1718
- setFilter
@@ -32,15 +33,6 @@ reference:
3233
- title: reorganise tables
3334
contents:
3435
- reorganise
35-
- title: other helper functions
36-
contents:
37-
- .eval_find
38-
- .eval_sum
39-
- .expect_valid_table
40-
- .getColTypes
41-
- .tidyVars
42-
- .updateFormat
43-
- show,schema-method
4436
- title: example data
4537
contents:
4638
- tabs2shift

man/dot-eval_find.Rd

Lines changed: 0 additions & 25 deletions
This file was deleted.

man/dot-eval_sum.Rd

Lines changed: 0 additions & 22 deletions
This file was deleted.

man/dot-expect_valid_table.Rd

Lines changed: 0 additions & 35 deletions
This file was deleted.

man/dot-fill.Rd

Lines changed: 0 additions & 18 deletions
This file was deleted.

man/dot-getColTypes.Rd

Lines changed: 0 additions & 18 deletions
This file was deleted.

man/dot-tidyVars.Rd

Lines changed: 0 additions & 23 deletions
This file was deleted.

man/dot-updateFormat.Rd

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)