How to center flushed-right column text in Kable?Aligning Columns with knitr kable functionRMarkdown kable vertically align cellsHow to wrap text in LaTeX tables?How to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)General guide for creating publication quality tables using R, Sweave, and LaTeXKnitr creates black box blocking name of first column when creating a tableHow can I subscript names in a table from kable()?R Kable: Rotating Text in Column GroupingHow to remove/hide column names in kable?Replace column names in kable/R markdownR kableExtra latex: Add linebreaks to rotated header row
Exploiting the delay when a festival ticket is scanned
How to prevent a single-element caster from being useless against immune foes?
Security measures that could plausibly last 150+ years?
Is it bad style if the personal first person narrator of a story dies during said story?
Why tantalum for the Hayabusa bullets?
Road bike front wheel question
Should students have access to past exams or an exam bank?
Solve equation using Mathematica
"Valet parking " or "parking valet"
What is a Trio Word™?
Why didn't Stark and Nebula use jump points with their ship to go back to Earth?
What are the closest international airports in different countries?
Is it possible for a particle to decay via gravity?
How did astronauts using rovers tell direction without compasses on the Moon?
How to have poached eggs in "sphere form"?
Does Ubuntu reduce battery life?
Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?
Why doesn't the Gottesman-Knill theorem render quantum computing almost useless?
Dynamic Icon loading in LWC doesn't work
When encrypting twice with two separate keys, can a single key decrypt both steps?
Scam? Checks via Email
Embedded C - Most elegant way to insert a delay
Just how much information should you share with a former client?
My employer is refusing to give me the pay that was advertised after an internal job move
How to center flushed-right column text in Kable?
Aligning Columns with knitr kable functionRMarkdown kable vertically align cellsHow to wrap text in LaTeX tables?How to sort a dataframe by multiple column(s)How to join (merge) data frames (inner, outer, left, right)General guide for creating publication quality tables using R, Sweave, and LaTeXKnitr creates black box blocking name of first column when creating a tableHow can I subscript names in a table from kable()?R Kable: Rotating Text in Column GroupingHow to remove/hide column names in kable?Replace column names in kable/R markdownR kableExtra latex: Add linebreaks to rotated header row
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am having a dataframe with both character and numeric columns. I am trying to center the character column (which is done) and (I don't know how to) center flushed-right numeric column. Further, both column names are centered:
Some relevant posts (this and this), but I couldn't incorporate the techniques (if relevant) to my code.
The following code produces the table below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df, format="latex", align = c("c", "r")) %>%
kable_styling(full_width = TRUE) %>%
row_spec(0, align = "c")
I understand that I can use LaTeX code to produce a single user-customised table. But I need the example to be reproducible in Rmd (imagine I have lots of df
) and therefore need to specify within kable()
.
Should I modify the LaTeX table environment (i.e. begintabu to linewidth >centeringX>centeringX
) and if so how in R, or use something like multirow
to customise the second column??
r latex r-markdown kable
add a comment |
I am having a dataframe with both character and numeric columns. I am trying to center the character column (which is done) and (I don't know how to) center flushed-right numeric column. Further, both column names are centered:
Some relevant posts (this and this), but I couldn't incorporate the techniques (if relevant) to my code.
The following code produces the table below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df, format="latex", align = c("c", "r")) %>%
kable_styling(full_width = TRUE) %>%
row_spec(0, align = "c")
I understand that I can use LaTeX code to produce a single user-customised table. But I need the example to be reproducible in Rmd (imagine I have lots of df
) and therefore need to specify within kable()
.
Should I modify the LaTeX table environment (i.e. begintabu to linewidth >centeringX>centeringX
) and if so how in R, or use something like multirow
to customise the second column??
r latex r-markdown kable
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
This combo does not appear to be possible directly inkable
. You may be able to fake it usingsprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions,xtable
, and something inhmisc
, also the packagetables
. Good luck.
– lmo
Mar 27 at 0:49
1
Will give these options a try!
– Jane
Mar 27 at 20:23
add a comment |
I am having a dataframe with both character and numeric columns. I am trying to center the character column (which is done) and (I don't know how to) center flushed-right numeric column. Further, both column names are centered:
Some relevant posts (this and this), but I couldn't incorporate the techniques (if relevant) to my code.
The following code produces the table below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df, format="latex", align = c("c", "r")) %>%
kable_styling(full_width = TRUE) %>%
row_spec(0, align = "c")
I understand that I can use LaTeX code to produce a single user-customised table. But I need the example to be reproducible in Rmd (imagine I have lots of df
) and therefore need to specify within kable()
.
Should I modify the LaTeX table environment (i.e. begintabu to linewidth >centeringX>centeringX
) and if so how in R, or use something like multirow
to customise the second column??
r latex r-markdown kable
I am having a dataframe with both character and numeric columns. I am trying to center the character column (which is done) and (I don't know how to) center flushed-right numeric column. Further, both column names are centered:
Some relevant posts (this and this), but I couldn't incorporate the techniques (if relevant) to my code.
The following code produces the table below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df, format="latex", align = c("c", "r")) %>%
kable_styling(full_width = TRUE) %>%
row_spec(0, align = "c")
I understand that I can use LaTeX code to produce a single user-customised table. But I need the example to be reproducible in Rmd (imagine I have lots of df
) and therefore need to specify within kable()
.
Should I modify the LaTeX table environment (i.e. begintabu to linewidth >centeringX>centeringX
) and if so how in R, or use something like multirow
to customise the second column??
r latex r-markdown kable
r latex r-markdown kable
edited Mar 26 at 21:30
Jane
asked Mar 26 at 21:25
JaneJane
13510 bronze badges
13510 bronze badges
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
This combo does not appear to be possible directly inkable
. You may be able to fake it usingsprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions,xtable
, and something inhmisc
, also the packagetables
. Good luck.
– lmo
Mar 27 at 0:49
1
Will give these options a try!
– Jane
Mar 27 at 20:23
add a comment |
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
This combo does not appear to be possible directly inkable
. You may be able to fake it usingsprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions,xtable
, and something inhmisc
, also the packagetables
. Good luck.
– lmo
Mar 27 at 0:49
1
Will give these options a try!
– Jane
Mar 27 at 20:23
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
This combo does not appear to be possible directly in
kable
. You may be able to fake it using sprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions, xtable
, and something in hmisc
, also the package tables
. Good luck.– lmo
Mar 27 at 0:49
This combo does not appear to be possible directly in
kable
. You may be able to fake it using sprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions, xtable
, and something in hmisc
, also the package tables
. Good luck.– lmo
Mar 27 at 0:49
1
1
Will give these options a try!
– Jane
Mar 27 at 20:23
Will give these options a try!
– Jane
Mar 27 at 20:23
add a comment |
1 Answer
1
active
oldest
votes
Thanks to @Fran from this post, answer below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df,"latex", align="cr", booktabs = T, linesep = "") %>%
kable_styling() %>%
column_spec(1, width = "3em") %>%
column_spec(2, width = "3em")
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366429%2fhow-to-center-flushed-right-column-text-in-kable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to @Fran from this post, answer below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df,"latex", align="cr", booktabs = T, linesep = "") %>%
kable_styling() %>%
column_spec(1, width = "3em") %>%
column_spec(2, width = "3em")
add a comment |
Thanks to @Fran from this post, answer below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df,"latex", align="cr", booktabs = T, linesep = "") %>%
kable_styling() %>%
column_spec(1, width = "3em") %>%
column_spec(2, width = "3em")
add a comment |
Thanks to @Fran from this post, answer below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df,"latex", align="cr", booktabs = T, linesep = "") %>%
kable_styling() %>%
column_spec(1, width = "3em") %>%
column_spec(2, width = "3em")
Thanks to @Fran from this post, answer below:
df <- data.frame(name = c("a", "bb", "ccc"), number = c(10, 193048, 200))
kable(df,"latex", align="cr", booktabs = T, linesep = "") %>%
kable_styling() %>%
column_spec(1, width = "3em") %>%
column_spec(2, width = "3em")
answered Mar 29 at 22:41
JaneJane
13510 bronze badges
13510 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366429%2fhow-to-center-flushed-right-column-text-in-kable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
My answer here might be relevant. It doesn't use Latex directly, though.
– lmo
Mar 27 at 0:28
Thank you @Imo, I may have missed it, but I didn't see any info on center and right alignment for the column.
– Jane
Mar 27 at 0:36
This combo does not appear to be possible directly in
kable
. You may be able to fake it usingsprintf
with the proper formatting, ie adding enough blank spaces to get it to look good enough. Take a look at the examples in the manual page if you want to give that a try. Alternatively, there are a number of alternative table functions,xtable
, and something inhmisc
, also the packagetables
. Good luck.– lmo
Mar 27 at 0:49
1
Will give these options a try!
– Jane
Mar 27 at 20:23