-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests@208 support for newline@main #746
Changes from 10 commits
08ed785
e3dfa6f
26327c6
ae2c3d1
2e4cae5
ecc1bb8
7994851
75eb2f6
5c67515
cf27faf
de4806a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -531,12 +531,12 @@ get_formatted_fnotes <- function(tt) { | |
if(lentl == 0) { | ||
tl <- rep("", nli) | ||
} else if(lentl > nli) { | ||
npad <- lentl - nli | ||
body <- rbind(matrix("", nrow = npad, ncol = ncol(body)), body) | ||
span <- rbind(matrix(1, nrow = npad, ncol = ncol(span)), span) | ||
fnote <- rbind(matrix(list(), nrow = npad, ncol = ncol(body)), fnote) | ||
tl_tmp <- paste0(tl, collapse = "\n") | ||
tl <- rep("", nli) | ||
tl[length(tl)] <- tl_tmp | ||
} else if (lentl < nli) { | ||
tl <- c(tl, rep("", nli - lentl)) | ||
# We want topleft alignment that goes to the bottom! | ||
tl <- c(rep("", nli - lentl), tl) | ||
Comment on lines
+538
to
+539
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is important imo @shajoezhu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the align bottom of top_left |
||
} | ||
list(body = cbind(tl, body, deparse.level = 0), span = cbind(1, span), | ||
footnotes = cbind(list(list()), fnote)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,7 @@ test_that("newline in column names and possibly cell values work", { | |
expect_identical(mf_nlheader(matform2), | ||
4L) | ||
expect_identical(matform2$strings[1:4, 1, drop = TRUE], | ||
c("Ethnicity", " Factor2", "", "")) | ||
c("", "", "Ethnicity", " Factor2")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now It is bottom aligned |
||
|
||
## cell has \n | ||
|
||
|
@@ -543,3 +543,54 @@ test_that("row label indentation is kept even if there are newline characters", | |
"Found newline characters" | ||
) | ||
}) | ||
|
||
test_that("Support for newline characters in all the parts", { | ||
set.seed(1) | ||
DM_trick <- DM %>% | ||
mutate(ARM2 = sample(c("TWO\nwords\n", "A wo\n\nrd"), | ||
replace = TRUE, nrow(DM))) # last \n is eaten up | ||
levels(DM_trick$SEX)[3] <- "U\nN\nD\n" | ||
tbl <- basic_table() %>% | ||
split_rows_by("SEX", split_label = "m\nannaggia\nsda\n", | ||
label_pos = "visible") %>% # last \n bug | ||
split_cols_by("ARM2", split_label = "sda") %>% | ||
analyze("BMRKR1", na_str = "asd\nasd") %>% # \n error | ||
build_table(DM_trick) | ||
|
||
top_left(tbl) <- c("\na", "b\nd\n\n", "c\n\n") # last \n is eaten up, if in the middle error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. first \n are kept ->> note that if you want a blank line you could even do "\n " as group of spaces are considered words now |
||
main_title(tbl) <- "why not \nalso here\n" | ||
out <- strsplit(toString(tbl, hsep = "-"), "\\n")[[1]] | ||
expected <- c( | ||
"why not ", | ||
"also here", | ||
"", | ||
"", | ||
"---------------------------------", | ||
" ", | ||
"a ", | ||
"b ", | ||
"d ", | ||
" ", | ||
" A wo", | ||
"c TWO ", | ||
" words rd ", | ||
"---------------------------------", | ||
"m ", | ||
"annaggia ", | ||
"sda ", | ||
" F ", | ||
" Mean 5.81 6.29", | ||
" M ", | ||
" Mean 6.15 5.21", | ||
" U ", | ||
" N ", | ||
" D ", | ||
" ", | ||
" Mean asd asd ", | ||
" asd asd ", | ||
" UNDIFFERENTIATED ", | ||
" Mean asd asd ", | ||
" asd asd " | ||
) | ||
expect_identical(out, expected) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exported was changed because now the extra line to pop is above and not below (top_left is bottom aligned)