Placing a table with an archer and a knife

I have a document knitrwith a table of regression results in the form of output stargazer, for example:

\documentclass[11pt]{article}
\begin{document}

<<setup, echo = FALSE, results= 'hide', message = FALSE>>=
data(mtcars)
library(stargazer)
@

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend molestie nisi, id scelerisque orci venenatis imperdiet. Fusce dictum congue faucibus. Phasellus mollis bibendum tellus eu interdum. Nam sollicitudin congue fringilla. Donec rhoncus viverra lorem vel molestie. Ut varius facilisis ante, a pretium arcu feugiat in. Maecenas sagittis accumsan massa. Pellentesque sollicitudin odio non odio elementum vel tristique dui mattis. Pellentesque tempus feugiat magna, a pharetra ipsum posuere ac. Donec fringilla ligula nec tellus egestas dictum. Vestibulum sit amet sem elit. Vestibulum nibh purus, pulvinar nec hendrerit sollicitudin, posuere ac mi. Cras mollis lorem ac mauris pellentesque elementum. In venenatis laoreet ligula.

<<echo=FALSE, results='asis', comment=NA>>=
model1 <- lm(mpg ~ gear, data=mtcars)
stargazer(model1)
@
\end{document}

How to influence the placement of this table in the document or, in other words, how to transfer the position specifier to the table environment stargazer? I looked through the manual , but left blank.

+5
source share
2 answers

Starting with version 4.0 (now available in CRAN), you can easily adjust the placement of the table using the table.placement argument.

+4
source

One way to do this is to replace the placement argument with regular expressions.

If you check the output of stargazer, you will notice that the default value

[4] "\\begin{table}[htb] \\centering " 

htb .

x <- stargazer(model1)
gsub("\\[htb\\]", "[h]", x)
 [4] "\\begin{table}[h] \\centering " 
+2

All Articles