Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Jun 26, 2024
1 parent c3648e3 commit f9dc753
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion R/ard_continuous.survey.design.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ ard_continuous.survey.design <- function(data, variables, by = NULL,
fmt_fn = map(.data$variable, ~ fmt_fn[[.x]] |> unname())
) |>
tidyr::unnest(cols = c("stat_name", "fmt_fn")),
by = "stat_name",
by = c("variable", "stat_name"),
unmatched = "ignore"
)
}
Expand Down
23 changes: 12 additions & 11 deletions tests/testthat/_snaps/ard_continuous.survey.design.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@
# ard_continuous.survey.design(fmt_fn)

Code
ard_continuous(dclus1, variables = api00, statistic = ~ c("mean", "median",
"min", "max"), fmt_fn = list(api00 = list(mean = 2, median = "xx.xx", min = as.character)))
Message
{cards} data frame: 4 x 8
as.data.frame(dplyr::select(ard_continuous(dclus1, variables = c(api99, api00),
statistic = ~ c("mean", "median", "min", "max"), fmt_fn = list(api00 = list(
mean = 2, median = "xx.xx", min = as.character))), -warning, -error))
Output
variable context stat_name stat_label stat fmt_fn
1 api00 continuo… mean Mean 644.169 2
2 api00 continuo… median Median 652 xx.xx
3 api00 continuo… min Minimum 411 <fn>
4 api00 continuo… max Maximum 905 1
Message
i 2 more variables: warning, error
variable context stat_name stat_label stat fmt_fn
1 api99 continuous mean Mean 606.9781 1
2 api99 continuous median Median 615 1
3 api99 continuous min Minimum 365 1
4 api99 continuous max Maximum 890 1
5 api00 continuous mean Mean 644.1694 2
6 api00 continuous median Median 652 xx.xx
7 api00 continuous min Minimum 411 .Primitive("as.character")
8 api00 continuous max Maximum 905 1

# ard_continuous.survey.design(stat_label)

Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-ard_continuous.survey.design.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,12 @@ test_that("ard_continuous.survey.design(fmt_fn)", {
expect_snapshot(
ard_continuous(
dclus1,
variables = api00,
variables = c(api99, api00),
statistic = ~ c("mean", "median", "min", "max"),
fmt_fn = list(api00 = list(mean = 2, median = "xx.xx", min = as.character))
)
) |>
dplyr::select(-warning, -error) |>
as.data.frame()
)
})

Expand Down

0 comments on commit f9dc753

Please sign in to comment.