kableExtra icon indicating copy to clipboard operation
kableExtra copied to clipboard

Vectorize arguments to `row_spec` to allow control of individual cell elements.

Open warnes opened this issue 2 years ago • 6 comments

This resolves #773 by vectorizing the arguments to row_spec and sub-functions.

Example use from the update man page:

x <- head(mtcars)
k <- knitr::kable(x, "html")

# First two rows bold and italic
row_spec(k, 1:2, bold = TRUE, italic = TRUE)

image

# Color one header background red with white text
row_spec(k, 
         row = 0, 
         background=c("","red",rep("",9)),
         color=c("","white",rep("",9))
         )

image

# Color columns of header alternating grey and green, via recycling
row_spec(k, 0, color=c('grey','green'))

image

# Color columns alternating grey and green in all rows, via recycling
row_spec(k, 0:nrow(x), color=c('grey','green'))

image

# Same thing using `column_spec`:
k |>
column_spec(seq(1, ncol(x)+1, by=2), color='grey') |>
column_spec(seq(2, ncol(x)+1, by=2), color='green')

image

warnes avatar Nov 04 '23 17:11 warnes

The conflicts are pretty easy to resolve, but I'm not sure how to add them to the PR. @haozhu233 should take a look and decide whether the changes are desirable.

dmurdoch avatar Dec 01 '23 20:12 dmurdoch

@dmurdoch I merged in the changes from master and resolved the conflicts.

warnes avatar Dec 02 '23 20:12 warnes

I think something went wrong in the merge - the removal of spec_barplot (from mini_plots.R) was intentional, and it looks like your change restores it.

dmurdoch avatar Dec 02 '23 21:12 dmurdoch

Sure, I think this feature aligns with what we have in column_spec (https://github.com/haozhu233/kableExtra/commit/33b865f485c8b394505f202d13c83b60b8a26c5f). @warnes If you get remove spec_barplot that would be great!

I will do a few more testings tonight.

haozhu233 avatar Dec 03 '23 21:12 haozhu233

I’ll fix that tomorrow.

On Sun, Dec 3, 2023 at 5:00 PM Hao Zhu @.***> wrote:

Sure, I think this feature aligns with what we have in column_spec ( 33b865f https://github.com/haozhu233/kableExtra/commit/33b865f485c8b394505f202d13c83b60b8a26c5f). @warnes https://github.com/warnes If you get remove spec_barplot that would be great!

I will do a few more testings tonight.

— Reply to this email directly, view it on GitHub https://github.com/haozhu233/kableExtra/pull/774#issuecomment-1837612928, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO4GX6K353KEZAHKCK5ZM3YHTY57AVCNFSM6AAAAAA65XGXO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXGYYTEOJSHA . You are receiving this because you were mentioned.Message ID: @.***>

warnes avatar Dec 03 '23 23:12 warnes

Removed spec_barplot from mini_plots.R and resolved merge conflict.

warnes avatar Jan 17 '24 18:01 warnes