Aligning Columns with knitr kable function

前端 未结 3 1415
青春惊慌失措
青春惊慌失措 2021-01-07 17:54

I am performing a simple task: creating a table and outputting it using R Markdown to pdf as follows:

library(knitr)
kable(datatabl         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 18:35

    You can also use the length function to create a vector for all rows in a vector/dataframe without having to hard code a length. The example below left-aligns all the columns in the mtcars data frame no matter the length.

     kable(mtcars, align=rep('l', length(mtcars[,1])))
    

提交回复
热议问题