stargazer left align LaTeX table columns

女生的网名这么多〃 提交于 2019-12-03 10:47:21

As has been pointed out in the comments, you could either post-process the output of stargazer, or use xtable. I'll demonstrate both approaches.

  1. post-processing: Replace your code chuck with the following two code chunks

    <<echo=FALSE, results=hide>>=
    library(stargazer)
    tab <- stargazer(iris[1:10,4:5], summary  = FALSE) 
    @
    
    <<results=tex, echo=FALSE>>=
    collapse <- function(st) paste(st, collapse="")
    st <- gsub(collapse(rep("c", 3)), collapse(rep("l",3)), tab)
    cat(st[4:24])
    @
    
  2. xtable: After installing the xtable package, you could use this as your code chuck

    <<iris, results="asis", echo=FALSE>>=
    library(xtable)
    print(xtable(iris[1:10,4:5], align="lll", caption=""))
    @
    

I think the xtable approach is probably easier though

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!