Conversation
…re shadows on other columns in order to fix merge issue
|
Hey @kinto-b , just making some changes to support GOSL reporting. Would you mind reviewing when you get a chance? |
|
@paddytobias Yo! Is the intention here to use the name provided in the shadow (for one-place shadows) as the name of the column? For example The only issue I can see is that providing the same named one-place shadow for multiple columns will now throw an error. For instance: tbl <- mtcars %>%
prj_tbl_rows(
Cylinders = cyl,
Transmission = list(Automatic = am %in% 0, Manual = am %in% 1),
) %>%
prj_tbl_cols(
`V-Shaped` = col_freq(n = vs %in% 1, N = vs %in% 0:1),
`Not V-shaped` = col_freq(n = vs %in% 0, N = vs %in% 0:1)
) %>%
prj_tbl_summarise()
tbl %>%
prj_project(list(
`V-Shaped` = c(p = "{signif(p, 2)} ({n})"),
`Not V-shaped` = c(p = "{signif(p, 2)} ({n})")
))It would be good to handle this behind the scenes and signal a warning. Other than that, could you also add:
|
|
Thanks @kinto-b for thinking this through more, I've added some internal handling for duplicate column names. A increment suffix is added to the name and a warning is thrown library(projectable)
library(magrittr)
#> Warning: package 'magrittr' was built under R version 4.0.5
tbl <- mtcars %>%
prj_tbl_rows(
Cylinders = cyl,
Transmission = list(Automatic = am %in% 0, Manual = am %in% 1),
) %>%
prj_tbl_cols(
`V-Shaped` = col_freq(n = vs %in% 1, N = vs %in% 0:1),
`Not V-shaped` = col_freq(n = vs %in% 0, N = vs %in% 0:1)
) %>%
prj_tbl_summarise()
tbl %>%
prj_project(list(
`V-Shaped` = c(p = "{signif(p, 2)} ({n})"),
`Not V-shaped` = c(p = "{signif(p, 2)} ({n})")
))
#> Warning in prj_cast_shadow(.data, .digits = .digits):
#> Column name duplicated: `p`
#> Resolving by incrementing...
#> # A tibble: 5 x 4
#> row_spanner rows p1 p2
#> * <col_row> <col_row> <glue> <glue>
#> 1 Cylinders 4 0.91 (10) 0.09 (1)
#> 2 Cylinders 6 0.57 (4) 0.43 (3)
#> 3 Cylinders 8 0 (0) 1 (14)
#> 4 Transmission Automatic 0.37 (7) 0.63 (12)
#> 5 Transmission Manual 0.54 (7) 0.46 (6)Created on 2022-05-27 by the reprex package (v2.0.1) Have also added to the tests and added examples to the NEWS and function documentation |
R/public.R
Outdated
| dplyr::case_when( | ||
| is.na(x) | is.na(N) | N %in% 0 ~ "", # No records in cell | ||
| N < min_N ~ "n/a", # Too few records in cell | ||
| TRUE ~ dec_dig3(x, digits) | ||
| ) | ||
| } |
There was a problem hiding this comment.
I don't think importing the dplyr dep is worth it for just this case_when and the one below. This can easily be changed to a series of assignments:
x[is.na(x) | is.na(N) | N %in% 0] <- ""
# etc.
R/public.R
Outdated
|
|
||
| #' @export | ||
| #' @rdname public_formats | ||
| public_num <- function(x, N, digits = 1, min_N = 25) { |
There was a problem hiding this comment.
I'm still not entirely convinced these belong here. They're much more related to how SRC does reporting than the projectable class and associated methods. Also would be a bit cleaner to introduce these in a separate PR so that they have their own commit
|
Hey @paddytobias I've moved the public functions back to srcreporting and updated the versioning etc. I don't seem to have permissions to push my commits to github though. |
|
Hey @justanna95, I've just given you permissions, so should be good to go :) |
No description provided.