Skip to content

Commit 929df30

Browse files
committed
chore: update NAMESPACE and documentation; enhance split_tt function to preserve data frame structure
1 parent 217e0c3 commit 929df30

9 files changed

Lines changed: 29 additions & 12 deletions

File tree

NAMESPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ importFrom(dplyr,filter)
5555
importFrom(dplyr,mutate)
5656
importFrom(dplyr,select)
5757
importFrom(glue,glue)
58+
importFrom(graphics,hist)
5859
importFrom(magrittr,"%>%")
5960
importFrom(purrr,is_null)
6061
importFrom(purrr,map)
62+
importFrom(rlang,.data)
63+
importFrom(rlang,sym)
6164
importFrom(rstatix,chisq_test)
6265
importFrom(stats,chisq.test)
6366
importFrom(stats,fisher.test)
64-
importFrom(graphics,hist)
65-
importFrom(rlang,sym)
66-
importFrom(rlang,.data)
6767
importFrom(tibble,enframe)
6868
importFrom(tibble,tibble)
6969
importFrom(tidyr,drop_na)

R/chr_to_var.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' labels (`var_label`) provided by the user.
88
#'
99
#' @details
10-
#' This function is a wrapper around several other {surveytoolbox} functions:
10+
#' This function is a wrapper around several other surveytoolbox functions:
1111
#' - `create_named_list()`
1212
#' - `set_vall()`
1313
#' - `set_varl()`

R/extract_fa_loads.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
#' @param fa_object factanal() model
55
#' @keywords factor analysis
66
#'
7-
#'
8-
#' @examples
7+
#' @examples
8+
#' \dontrun{
99
#' fa_output <- stats::factanal(
1010
#' tidyr::drop_na(psych::bfi),
1111
#' factors = 6
1212
#' )
1313
#' extract_fa_loads(fa_output)
14+
#' }
15+
#'
1416
#' @export
1517
extract_fa_loads <-function(fa_object){
1618

R/globals.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
##
33
## This file is added to minimize the false positives flagged during R CMD check.
44

5+
#' @importFrom graphics hist
6+
#' @importFrom stats chisq.test
7+
#' @importFrom rlang .data sym
8+
NULL
59

610
utils::globalVariables(
711
c(
@@ -16,6 +20,12 @@ utils::globalVariables(
1620
"hclust",
1721
"dist",
1822
"t.test",
19-
"var_label"
23+
"var_label",
24+
"statistic",
25+
"p",
26+
"df",
27+
"method",
28+
"p.signif",
29+
"alternative"
2030
)
2131
)

R/split_tt.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
split_tt <-function(x, part){
1616
rowz <- nrow(x)
1717
samp <- sample(seq_len(rowz),floor(rowz * part))
18-
output <-list("train"=x[samp,],"test"=x[-samp,])
18+
output <-list("train"=x[samp, , drop = FALSE],"test"=x[-samp, , drop = FALSE])
1919
output
2020
}

R/ttest_nps.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ ttest_nps <- function(x, conf_level = 0.95){
3232
message()
3333
message("Returning margin of error:")
3434

35-
return(ci_range)
35+
return(as.numeric(ci_range))
3636
}

man/chr_to_var.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extract_fa_loads.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-statistical.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ test_that("ttest_nps returns margin of error", {
9393
set.seed(123)
9494
x <- sample(c(-100, 0, 100), 100, replace = TRUE)
9595

96-
# Capture the message and result
97-
result <- expect_message(ttest_nps(x))
96+
# Capture the result (suppress messages)
97+
result <- suppressMessages(ttest_nps(x))
9898

9999
expect_type(result, "double")
100100
expect_true(result > 0) # Margin of error should be positive
@@ -131,11 +131,13 @@ test_that("split_tt splits data correctly", {
131131
})
132132

133133
test_that("split_tt handles different proportions", {
134+
set.seed(123)
134135
df <- data.frame(x = 1:100)
135136

136137
result_80 <- split_tt(df, 0.8)
137138
result_50 <- split_tt(df, 0.5)
138139

140+
# split_tt now preserves data frame structure with drop = FALSE
139141
expect_equal(nrow(result_80$train), 80)
140142
expect_equal(nrow(result_50$train), 50)
141143
})

0 commit comments

Comments
 (0)