dbosak01 / reporter

An R package to write statistical reports.
Creative Commons Zero v1.0 Universal
16 stars 3 forks source link

Prepending row number to a wide table that spans over multiple pages #293

Closed omadios closed 1 year ago

omadios commented 1 year ago

Hello David,

first of all thank you for making this amazing package available!

I have a wide table that spans (horizontally) over multiple pages in landscape mode.

Is it possible to prepend a row number in front of each row (let's say that 10 columns are in page 1 and another 10 columns are in page 2, I would like to have a row number to identify matching rows across the two pages?)

I couldn't find a way to do it in the instructions.

Thank you!

dbosak01 commented 1 year ago

omadios:

Thanks. Yes, there is a parameter on the define() function called "id_var". It tells write_report() to repeat that column on each page wrap. Here are a couple examples: https://reporter.r-sassy.org/articles/reporter-wrap.html https://sassy.r-sassy.org/articles/sassy-listing.html

Basically you create the row number on the input data frame. Then define() that column and set id_var=TRUE. If you can't figure it out from this explanation and the examples, let me know and I'll write some sample code for you.

Best regards,

David

omadios commented 1 year ago

Ah my bad, excellent, that works!

(PS thanks for answering so promptly, I am two days ahead of a big submission deadline...)

All the best,

Marcello

Pasting an example of working code for other viewers

res <- cbind(row = c(1:nrow(res)), res) mytable <- create_table(res,borders = c("inside","bottom","right","top")) %>% define(row, label = " ", width = 0.2, id_var = TRUE, align = "left")