Skip to content
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

Table corruption #108

Closed
mchastkofsky opened this issue Jun 27, 2022 · 5 comments
Closed

Table corruption #108

mchastkofsky opened this issue Jun 27, 2022 · 5 comments

Comments

@mchastkofsky
Copy link

mchastkofsky commented Jun 27, 2022

I have been converting data in make_table1 into rtf tables for output, but when I try to open the rtf, I get an error stating that the table has been corrupted. It specifically happens when the table is longer than 1 page. The rtf file will still open, and the table looks good, but I still get the warning any time I open the file.

xdata %>%
rtf_page(
margin = c(1.5, 1, 1, 0.75, 0.25, 0.25),
border_first = "single",
border_last = "single"
) %>%
rtf_colheader(colheader = paste0(" | ", "a_d_sz", " \n n = ", "a_n_sz", " | ", "b_d_sz", " \n n = ", "b_n_sz", "| "),
col_rel_width = c(3, 1, 1, 1),
#border_top = "single",
text_font = 3) %>%
rtf_colheader(colheader = "Characteristic | n (%) or mean (SD) | n (%) or mean (SD) | SMD",
col_rel_width = c(3, rep(1,3)),
border_top = "",
text_font = 3) %>%
rtf_body(
col_rel_width = c(3, rep(1,3)),
text_justification = c("l", rep("d",3)),
cell_nrow = 1,
text_font_size = 9,
text_font = 3
) %>%
rtf_encode(
doc_type = "table",
page_footnote = "all",
page_source = "all"
) %>%
write_rtf("test.rtf")

@elong0527
Copy link
Collaborator

My initial guess is of using \chpgn of {\field{\*\fldinst NUMPAGES }} .

Please try to rerun after removing two functions rtf_footnote and rtf_page_footer and see if you still get the same issue.

The code is also not reproducible as we can not access xdata.

If it is not confidential, could you attach the test.rtf file and xdata? Or create a dummy dataset to reproduce the issue.

@mchastkofsky
Copy link
Author

I removed several lines, (I edited the above code) and I still get the same error. The data is confidential, so I can't attach it directly, but I can try to create a dummy dataset and see what happens.

@mchastkofsky
Copy link
Author

It wouldn't let me upload the rtf file (apparently it isn't supported), but here is a dummy dataset along with the code.

xdata %>% rtf_page( margin = c(1.5, 1, 1, 0.75, 0.25, 0.25), border_first = "single", border_last = "single" ) %>% rtf_colheader(colheader = paste0(" | ", "a_d_sz", " \n n = ", "a_n_sz", " | ", "b_d_sz", " \n n = ", "b_n_sz", "| "), col_rel_width = c(3, 1, 1, 1), #border_top = "single", text_font = 3) %>% rtf_colheader(colheader = "Characteristic | n (%) or mean (SD) | n (%) or mean (SD) | SMD", col_rel_width = c(3, rep(1,3)), border_top = "", text_font = 3) %>% rtf_body( col_rel_width = c(3, rep(1,3)), text_justification = c("l", rep("d",3)), cell_nrow = 1, text_font_size = 9, text_font = 3 ) %>% rtf_encode( doc_type = "table", page_footnote = "all", page_source = "all" ) %>% write_rtf("test.rtf")

xdata.csv

@elong0527
Copy link
Collaborator

I am able to rerun your code after remove cell_nrow=1 and open rtf file without any warning or error.

Please try it in this project.

https://rstudio.cloud/project/4234539

I need to fix the bug when cell_nrow=1 is specified. That is document in a separate issue in #109.

@mchastkofsky
Copy link
Author

Okay, great, thanks! I am not in the office this week, so I won't be able to run it on my project until next Monday, but I took a look at the project in the could and yes, it looks like it resolved the error. I will check my project next week and let you know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants