Huxtable package for R: Align Columns Not Working As Expected in Knitted Doc











up vote
0
down vote

favorite












I am using RStudio version 1.1.456, which is running R version 3.5.1. I am running on Windows 7 Enterprise, 64-bit. I am using huxtable package version 4.3.0.



I'm trying to change various aspects of the huxtable when it is knitted to a word document. I'm finding that a lot of the options (such as right_padding, left_padding, width, or col_width) don't seem to be having any effect on the table formatting in either the word document, or when I test the formatting directly in the RStudio console.



In addition, the align function does not seem to be "listening". I am trying to left-align my first column:



ht1 <- as_hux(table(other_cei_data$location)) 
caption(ht1) <- "Where is your institution located?"
ht1[1,1] <- "Location" ## add proper col names
ht1[1,2] <- "Frequency"
align(ht1)[,1] <- 'left'
ht1


When I use this code in the RStudio console, this works just fine.



console table



But when I knit to a word document, the first column is center aligned.



word document table



When I put in arguments 'center' and 'right', the column is aligned as expected. I've also noticed that the default for the table in Word is for the first column to be left aligned until I add my column name. If I don't add any column names, the default is left-aligned, but regardless of what I specify, the column is always left-aligned.



I've also tried building a hux table manually with the same result (code below); 'right' and 'center' work fine, but 'left' is center-aligned:



ht1b <-hux(Location = c("Elsewhere in Canada","Ontario","USA or International"), 
Frequency = c(10,13,4),
add_colnames = TRUE)
align(ht1b)[,1] <- 'left'
ht1b


I'm not sure what I'm doing wrong, but I'm hoping someone can help. I'd really like to be able to use huxtable, as it seems like the best option for tables in RMarkdown reports, but I'm finding that the customization is not behaving as expected.



Thanks in advance for your help!










share|improve this question






















  • This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
    – dash2
    2 days ago















up vote
0
down vote

favorite












I am using RStudio version 1.1.456, which is running R version 3.5.1. I am running on Windows 7 Enterprise, 64-bit. I am using huxtable package version 4.3.0.



I'm trying to change various aspects of the huxtable when it is knitted to a word document. I'm finding that a lot of the options (such as right_padding, left_padding, width, or col_width) don't seem to be having any effect on the table formatting in either the word document, or when I test the formatting directly in the RStudio console.



In addition, the align function does not seem to be "listening". I am trying to left-align my first column:



ht1 <- as_hux(table(other_cei_data$location)) 
caption(ht1) <- "Where is your institution located?"
ht1[1,1] <- "Location" ## add proper col names
ht1[1,2] <- "Frequency"
align(ht1)[,1] <- 'left'
ht1


When I use this code in the RStudio console, this works just fine.



console table



But when I knit to a word document, the first column is center aligned.



word document table



When I put in arguments 'center' and 'right', the column is aligned as expected. I've also noticed that the default for the table in Word is for the first column to be left aligned until I add my column name. If I don't add any column names, the default is left-aligned, but regardless of what I specify, the column is always left-aligned.



I've also tried building a hux table manually with the same result (code below); 'right' and 'center' work fine, but 'left' is center-aligned:



ht1b <-hux(Location = c("Elsewhere in Canada","Ontario","USA or International"), 
Frequency = c(10,13,4),
add_colnames = TRUE)
align(ht1b)[,1] <- 'left'
ht1b


I'm not sure what I'm doing wrong, but I'm hoping someone can help. I'd really like to be able to use huxtable, as it seems like the best option for tables in RMarkdown reports, but I'm finding that the customization is not behaving as expected.



Thanks in advance for your help!










share|improve this question






















  • This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
    – dash2
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using RStudio version 1.1.456, which is running R version 3.5.1. I am running on Windows 7 Enterprise, 64-bit. I am using huxtable package version 4.3.0.



I'm trying to change various aspects of the huxtable when it is knitted to a word document. I'm finding that a lot of the options (such as right_padding, left_padding, width, or col_width) don't seem to be having any effect on the table formatting in either the word document, or when I test the formatting directly in the RStudio console.



In addition, the align function does not seem to be "listening". I am trying to left-align my first column:



ht1 <- as_hux(table(other_cei_data$location)) 
caption(ht1) <- "Where is your institution located?"
ht1[1,1] <- "Location" ## add proper col names
ht1[1,2] <- "Frequency"
align(ht1)[,1] <- 'left'
ht1


When I use this code in the RStudio console, this works just fine.



console table



But when I knit to a word document, the first column is center aligned.



word document table



When I put in arguments 'center' and 'right', the column is aligned as expected. I've also noticed that the default for the table in Word is for the first column to be left aligned until I add my column name. If I don't add any column names, the default is left-aligned, but regardless of what I specify, the column is always left-aligned.



I've also tried building a hux table manually with the same result (code below); 'right' and 'center' work fine, but 'left' is center-aligned:



ht1b <-hux(Location = c("Elsewhere in Canada","Ontario","USA or International"), 
Frequency = c(10,13,4),
add_colnames = TRUE)
align(ht1b)[,1] <- 'left'
ht1b


I'm not sure what I'm doing wrong, but I'm hoping someone can help. I'd really like to be able to use huxtable, as it seems like the best option for tables in RMarkdown reports, but I'm finding that the customization is not behaving as expected.



Thanks in advance for your help!










share|improve this question













I am using RStudio version 1.1.456, which is running R version 3.5.1. I am running on Windows 7 Enterprise, 64-bit. I am using huxtable package version 4.3.0.



I'm trying to change various aspects of the huxtable when it is knitted to a word document. I'm finding that a lot of the options (such as right_padding, left_padding, width, or col_width) don't seem to be having any effect on the table formatting in either the word document, or when I test the formatting directly in the RStudio console.



In addition, the align function does not seem to be "listening". I am trying to left-align my first column:



ht1 <- as_hux(table(other_cei_data$location)) 
caption(ht1) <- "Where is your institution located?"
ht1[1,1] <- "Location" ## add proper col names
ht1[1,2] <- "Frequency"
align(ht1)[,1] <- 'left'
ht1


When I use this code in the RStudio console, this works just fine.



console table



But when I knit to a word document, the first column is center aligned.



word document table



When I put in arguments 'center' and 'right', the column is aligned as expected. I've also noticed that the default for the table in Word is for the first column to be left aligned until I add my column name. If I don't add any column names, the default is left-aligned, but regardless of what I specify, the column is always left-aligned.



I've also tried building a hux table manually with the same result (code below); 'right' and 'center' work fine, but 'left' is center-aligned:



ht1b <-hux(Location = c("Elsewhere in Canada","Ontario","USA or International"), 
Frequency = c(10,13,4),
add_colnames = TRUE)
align(ht1b)[,1] <- 'left'
ht1b


I'm not sure what I'm doing wrong, but I'm hoping someone can help. I'd really like to be able to use huxtable, as it seems like the best option for tables in RMarkdown reports, but I'm finding that the customization is not behaving as expected.



Thanks in advance for your help!







r rstudio r-markdown






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 16:59









Tam R

84




84












  • This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
    – dash2
    2 days ago


















  • This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
    – dash2
    2 days ago
















This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
– dash2
2 days ago




This sounds like a bug. Could you report it at the github site? Ta - huxtable author.
– dash2
2 days ago

















active

oldest

votes











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',
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435482%2fhuxtable-package-for-r-align-columns-not-working-as-expected-in-knitted-doc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435482%2fhuxtable-package-for-r-align-columns-not-working-as-expected-in-knitted-doc%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu