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

FR: add the option of naming the column of row.names #1933

Closed
3 tasks done
iago-pssjd opened this issue Dec 14, 2020 · 4 comments
Closed
3 tasks done

FR: add the option of naming the column of row.names #1933

iago-pssjd opened this issue Dec 14, 2020 · 4 comments
Assignees
Labels
bug Bugs

Comments

@iago-pssjd
Copy link

iago-pssjd commented Dec 14, 2020

I would like to explicit a name for the column of row.names so I try

d2 = head(mtcars)
kable(d2[, 1:5], col.names = c("car", names(d2[, 1:5])))
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

Maybe, another option would be allow a string for row.names as follows -kable(d2[, 1:5], row.names = "cars")-, so kable would understand it as a TRUE and further naming the column.

Thank you!

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui yihui added the bug Bugs label Apr 6, 2021
@atusy
Copy link
Collaborator

atusy commented Jul 26, 2022

I have experienced the same situation and worked around with tibble::rownames_to_column.

d2 = head(mtcars)
d2[1:5] |>
  tibble::rownames_to_column() |>
  kable(col.names = c("car", names(d2[1:5]))

allow a string for row.names

This may be confusing because users would analogize the similar behavior among col.names and row.names.

As documented, kable is a very simple table generator.
I think complex steps should come prior to kable when possible.

@yihui yihui closed this as completed in 0901218 Aug 31, 2023
@yihui
Copy link
Owner

yihui commented Aug 31, 2023

Should be fixed now. Thanks for the report!

@iago-pssjd
Copy link
Author

Thank you! @yihui

@yihui yihui self-assigned this Aug 31, 2023
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

3 participants