How to keep a TABLE “here defnitely” in R markdownHow to hold figure position with figure caption in pdf output of knitr?How to make a great R reproducible exampleChunk reference using knitr, r markdown and pandoc (pander)Using R Markdown chunks in R Sweave(Knitr)Conditional `echo` (or eval or include) in rmarkdown chunksConditionally display block of markdown text using knitrOverlapping Columns knitting R Markdown to PDFRMarkdown / pandoc fails to knit Pdf with latex color commandshow to get figure floated / surrounded by text etc. in R markdown?R Markdown / knitr: specify path for all input, temporary, and output filesHow to set df_print to tibble in markdown for a single R code chunk

Why use nominative in Coniugatio periphrastica passiva?

How could Dwarves prevent sand from filling up their settlements

Is being an extrovert a necessary condition to be a manager?

On a piano, are the effects of holding notes and the sustain pedal the same for a single chord?

How to draw with Tikz a chord parallel to AC that passes through a point?

Expand a hexagon

Presenting 2 results for one variable using a left brace

Vehemently against code formatting

What should I wear to go and sign an employment contract?

How did Jean Parisot de Valette, 49th Grand Master of the Order of Malta, die?

How to play vs. 1.e4 e5 2.Nf3 Nc6 3.Bc4 d6?

1950s or earlier book with electrical currents living on Pluto

Best practice for printing and evaluating formulas with the minimal coding

Managing heat dissipation in a magic wand

How do we properly manage transitions within a descriptive section?

Does George B Sperry logo on fold case for photos indicate photographer or case manufacturer?

Was Tyrion always a poor strategist?

Why "strap-on" boosters, and how do other people say it?

Department head said that group project may be rejected. How to mitigate?

Farthing / Riding

Story about encounter with hostile aliens

What city and town structures are important in a low fantasy medieval world?

Do 'destroy' effects count as damage?

Way of refund if scammed?



How to keep a TABLE “here defnitely” in R markdown


How to hold figure position with figure caption in pdf output of knitr?How to make a great R reproducible exampleChunk reference using knitr, r markdown and pandoc (pander)Using R Markdown chunks in R Sweave(Knitr)Conditional `echo` (or eval or include) in rmarkdown chunksConditionally display block of markdown text using knitrOverlapping Columns knitting R Markdown to PDFRMarkdown / pandoc fails to knit Pdf with latex color commandshow to get figure floated / surrounded by text etc. in R markdown?R Markdown / knitr: specify path for all input, temporary, and output filesHow to set df_print to tibble in markdown for a single R code chunk






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I want to keep a table created in an rmarkdown document that outputs to pdf locked in place and not flexibly fitting between text.



For example, my code is:



---
title: "Rest"
author: "Dowdy"
date: "3/23/2019"
output: pdf_document
---

```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)

```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```r cars
summary(cars)
library(stargazer)
library(data.table)
```

Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.


Hello friend.


begincenter
```r star, results='asis',echo=F,eval=T, message=FALSE

star = capture.output(stargazer(data.table(cars)[1:15],digits=3,type = "latex",summary=F,digits.extra = 2,header = F))

star = gsub("& \$([0-9]+)\$", "& \$ 0.000 \$", star)

cat(star)

```
endcenter

Welcome to my world of toys. Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.
Welcome to my world of toys.
Welcome to my world of toys. gs I am testing heloo.
Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.

Of all the things I am testing heloo. Of all the things I am testing heloo.

1. Test hi hihhihihih

2. why is this hiiii

3. why test test test


4. test test test


Unfortunately, the output is this:



enter image description here



I do not want the image to split up my numbered list and text this way. I want the order of the text and image to be exactly as I typed it in the rmarkdown document. Specifically, that numbered list and the paragraph about toys should appear all after the table as it is typed in the markdown.



For figures, this question tried to do what I want to do I believe. Of course, I am asking this for tables instead of figures, so the solution does not help me.










share|improve this question






























    1















    I want to keep a table created in an rmarkdown document that outputs to pdf locked in place and not flexibly fitting between text.



    For example, my code is:



    ---
    title: "Rest"
    author: "Dowdy"
    date: "3/23/2019"
    output: pdf_document
    ---

    ```r setup, include=FALSE
    knitr::opts_chunk$set(echo = TRUE)

    ```

    ## R Markdown

    This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

    When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

    ```r cars
    summary(cars)
    library(stargazer)
    library(data.table)
    ```

    Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.


    Hello friend.


    begincenter
    ```r star, results='asis',echo=F,eval=T, message=FALSE

    star = capture.output(stargazer(data.table(cars)[1:15],digits=3,type = "latex",summary=F,digits.extra = 2,header = F))

    star = gsub("& \$([0-9]+)\$", "& \$ 0.000 \$", star)

    cat(star)

    ```
    endcenter

    Welcome to my world of toys. Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.
    Welcome to my world of toys.
    Welcome to my world of toys. gs I am testing heloo.
    Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.

    Of all the things I am testing heloo. Of all the things I am testing heloo.

    1. Test hi hihhihihih

    2. why is this hiiii

    3. why test test test


    4. test test test


    Unfortunately, the output is this:



    enter image description here



    I do not want the image to split up my numbered list and text this way. I want the order of the text and image to be exactly as I typed it in the rmarkdown document. Specifically, that numbered list and the paragraph about toys should appear all after the table as it is typed in the markdown.



    For figures, this question tried to do what I want to do I believe. Of course, I am asking this for tables instead of figures, so the solution does not help me.










    share|improve this question


























      1












      1








      1








      I want to keep a table created in an rmarkdown document that outputs to pdf locked in place and not flexibly fitting between text.



      For example, my code is:



      ---
      title: "Rest"
      author: "Dowdy"
      date: "3/23/2019"
      output: pdf_document
      ---

      ```r setup, include=FALSE
      knitr::opts_chunk$set(echo = TRUE)

      ```

      ## R Markdown

      This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

      When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

      ```r cars
      summary(cars)
      library(stargazer)
      library(data.table)
      ```

      Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.


      Hello friend.


      begincenter
      ```r star, results='asis',echo=F,eval=T, message=FALSE

      star = capture.output(stargazer(data.table(cars)[1:15],digits=3,type = "latex",summary=F,digits.extra = 2,header = F))

      star = gsub("& \$([0-9]+)\$", "& \$ 0.000 \$", star)

      cat(star)

      ```
      endcenter

      Welcome to my world of toys. Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.
      Welcome to my world of toys.
      Welcome to my world of toys. gs I am testing heloo.
      Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.

      Of all the things I am testing heloo. Of all the things I am testing heloo.

      1. Test hi hihhihihih

      2. why is this hiiii

      3. why test test test


      4. test test test


      Unfortunately, the output is this:



      enter image description here



      I do not want the image to split up my numbered list and text this way. I want the order of the text and image to be exactly as I typed it in the rmarkdown document. Specifically, that numbered list and the paragraph about toys should appear all after the table as it is typed in the markdown.



      For figures, this question tried to do what I want to do I believe. Of course, I am asking this for tables instead of figures, so the solution does not help me.










      share|improve this question
















      I want to keep a table created in an rmarkdown document that outputs to pdf locked in place and not flexibly fitting between text.



      For example, my code is:



      ---
      title: "Rest"
      author: "Dowdy"
      date: "3/23/2019"
      output: pdf_document
      ---

      ```r setup, include=FALSE
      knitr::opts_chunk$set(echo = TRUE)

      ```

      ## R Markdown

      This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

      When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

      ```r cars
      summary(cars)
      library(stargazer)
      library(data.table)
      ```

      Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.


      Hello friend.


      begincenter
      ```r star, results='asis',echo=F,eval=T, message=FALSE

      star = capture.output(stargazer(data.table(cars)[1:15],digits=3,type = "latex",summary=F,digits.extra = 2,header = F))

      star = gsub("& \$([0-9]+)\$", "& \$ 0.000 \$", star)

      cat(star)

      ```
      endcenter

      Welcome to my world of toys. Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.Welcome to my world of toys.
      Welcome to my world of toys.
      Welcome to my world of toys. gs I am testing heloo.
      Of all the things I am testing heloo. Of all the things I am testing heloo. Of all the things I am testing heloo.

      Of all the things I am testing heloo. Of all the things I am testing heloo.

      1. Test hi hihhihihih

      2. why is this hiiii

      3. why test test test


      4. test test test


      Unfortunately, the output is this:



      enter image description here



      I do not want the image to split up my numbered list and text this way. I want the order of the text and image to be exactly as I typed it in the rmarkdown document. Specifically, that numbered list and the paragraph about toys should appear all after the table as it is typed in the markdown.



      For figures, this question tried to do what I want to do I believe. Of course, I am asking this for tables instead of figures, so the solution does not help me.







      r latex r-markdown knitr figure






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 3:32







      wolfsatthedoor

















      asked Mar 23 at 19:53









      wolfsatthedoorwolfsatthedoor

      1,802103262




      1,802103262






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I have to check this when I update my tex, and I might need a little more information on what you want exactly, but if you want to have the table in the middle of the text, all you need to do is remove the begincenter and endcenter. R chunks are really used as copy paste wherever you want, even working as web links if you want. Additionally, you can use kable() from knitr for tables and this sometimes helps sometimes makes things worse. I'll check back later when I have better internet.






          share|improve this answer

























          • No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

            – wolfsatthedoor
            Mar 23 at 21:54











          • I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

            – csugai
            Mar 23 at 22:01











          • This is shockingly difficult!

            – wolfsatthedoor
            Mar 24 at 22:35











          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317759%2fhow-to-keep-a-table-here-defnitely-in-r-markdown%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









          1














          I have to check this when I update my tex, and I might need a little more information on what you want exactly, but if you want to have the table in the middle of the text, all you need to do is remove the begincenter and endcenter. R chunks are really used as copy paste wherever you want, even working as web links if you want. Additionally, you can use kable() from knitr for tables and this sometimes helps sometimes makes things worse. I'll check back later when I have better internet.






          share|improve this answer

























          • No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

            – wolfsatthedoor
            Mar 23 at 21:54











          • I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

            – csugai
            Mar 23 at 22:01











          • This is shockingly difficult!

            – wolfsatthedoor
            Mar 24 at 22:35















          1














          I have to check this when I update my tex, and I might need a little more information on what you want exactly, but if you want to have the table in the middle of the text, all you need to do is remove the begincenter and endcenter. R chunks are really used as copy paste wherever you want, even working as web links if you want. Additionally, you can use kable() from knitr for tables and this sometimes helps sometimes makes things worse. I'll check back later when I have better internet.






          share|improve this answer

























          • No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

            – wolfsatthedoor
            Mar 23 at 21:54











          • I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

            – csugai
            Mar 23 at 22:01











          • This is shockingly difficult!

            – wolfsatthedoor
            Mar 24 at 22:35













          1












          1








          1







          I have to check this when I update my tex, and I might need a little more information on what you want exactly, but if you want to have the table in the middle of the text, all you need to do is remove the begincenter and endcenter. R chunks are really used as copy paste wherever you want, even working as web links if you want. Additionally, you can use kable() from knitr for tables and this sometimes helps sometimes makes things worse. I'll check back later when I have better internet.






          share|improve this answer















          I have to check this when I update my tex, and I might need a little more information on what you want exactly, but if you want to have the table in the middle of the text, all you need to do is remove the begincenter and endcenter. R chunks are really used as copy paste wherever you want, even working as web links if you want. Additionally, you can use kable() from knitr for tables and this sometimes helps sometimes makes things worse. I'll check back later when I have better internet.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 23 at 21:54

























          answered Mar 23 at 21:52









          csugaicsugai

          12510




          12510












          • No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

            – wolfsatthedoor
            Mar 23 at 21:54











          • I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

            – csugai
            Mar 23 at 22:01











          • This is shockingly difficult!

            – wolfsatthedoor
            Mar 24 at 22:35

















          • No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

            – wolfsatthedoor
            Mar 23 at 21:54











          • I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

            – csugai
            Mar 23 at 22:01











          • This is shockingly difficult!

            – wolfsatthedoor
            Mar 24 at 22:35
















          No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

          – wolfsatthedoor
          Mar 23 at 21:54





          No not quite what I want, you see how I have a list 1. 2. 3. 4.... and in the rmarkdown this appears before the figure? But when you compile, in the pdf it throws the table smack in the middle of the list? I want to stop that and force the table to be after the list

          – wolfsatthedoor
          Mar 23 at 21:54













          I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

          – csugai
          Mar 23 at 22:01





          I see. Sorry but I'll have to come back to this as this might be a problem with pdf compiling. I edited your code as before mentioned and ran 'knit to html' due to prior mentioned updating needed for tex, and it came out fine.

          – csugai
          Mar 23 at 22:01













          This is shockingly difficult!

          – wolfsatthedoor
          Mar 24 at 22:35





          This is shockingly difficult!

          – wolfsatthedoor
          Mar 24 at 22:35



















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317759%2fhow-to-keep-a-table-here-defnitely-in-r-markdown%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript