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

Vectorize arguments to row_spec to allow control of individual cell elements. #774

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

warnes
Copy link

@warnes warnes commented Nov 4, 2023

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

…rol whether vector arguments are `map`ped to rows, or held fixed for all rows.

* Add examples to `spec_barplot`.
* Correct documentation for some `spec_barplot` parameters.
@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 1, 2023

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.

Merge branch 'master' of github.com:haozhu233/kableExtra into haozhu233-master

# Conflicts:
#	R/mini_plots.R
#	R/row_spec.R
#	man/row_spec.Rd
#	man/spec_barplot.Rd
@warnes
Copy link
Author

warnes commented Dec 2, 2023

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

@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 2, 2023

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.

@haozhu233
Copy link
Owner

Sure, I think this feature aligns with what we have in column_spec (33b865f). @warnes If you get remove spec_barplot that would be great!

I will do a few more testings tonight.

@warnes
Copy link
Author

warnes commented Dec 3, 2023 via email

@warnes
Copy link
Author

warnes commented Jan 17, 2024

Removed spec_barplot from mini_plots.R and resolved merge conflict.

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

Successfully merging this pull request may close these issues.

Allow vector for row_spec(align=...)
3 participants