<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 1/19/21 12:03 PM, Doug Martin wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOGjeM2iKxyMMyvy9JMOZKQYJ-M2mm=TThP4BKpmk+DfvXxA0A@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div class="gmail_default" style="font-size:small">Scott (and
          all),</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">I have
          attached the LYX segment from one of our book chapters, along
          with a page from the compiled pdf file that contains</div>
        <div class="gmail_default" style="font-size:small">the resulting
          Table TS-2.1.</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">This tiny
          example illustrates how we currently make most of our tables
          using the kableExtra package (kable is included in knitr),</div>
        <div class="gmail_default" style="font-size:small">and if we had
          an R script to produce an LYX Table with the data frame (or
          data.table) as input, we would surely use it.<br>
        </div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">FYI, in case
          you want to compile the LYX file, you just need to strip out
          the Springer svmono (book templates) stuff, etc., in the</div>
        <div class="gmail_default" style="font-size:small">LaTeX
          preamble, install knitr and kableExtra from CRAN, and install
          the optimalPsiRho package with:</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">
          devtools::install_github("kjellpk/optimalRhoPsi").</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">Just before
          sending this I noticed the several other emails on the topic,
          and will take a look at them.</div>
        <div class="gmail_default" style="font-size:small"><br>
        </div>
        <div class="gmail_default" style="font-size:small">Thanks,</div>
        <div class="gmail_default" style="font-size:small">Doug<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Jan 18, 2021 at 11:27
          AM Scott Kostyshak <<a href="mailto:skostysh@lyx.org"
            moz-do-not-send="true">skostysh@lyx.org</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
          Mon, Jan 18, 2021 at 11:03:49AM -0800, Doug Martin wrote:<br>
          > On Mon, Jan 18, 2021 at 10:41 AM Scott Kostyshak <<a
            href="mailto:skostysh@lyx.org" target="_blank"
            moz-do-not-send="true">skostysh@lyx.org</a>> wrote:<br>
          > <br>
          > > On Mon, Jan 18, 2021 at 07:25:42PM +0100, Jean-Marc
          Lasgouttes wrote:<br>
          > > > Le 14/01/2021 à 05:34, Doug Martin a écrit :<br>
          > > > > JMarc and all,<br>
          > > > ><br>
          > > > > Tom and I use knitr extensively for R code
          chunks, and we mostly use<br>
          > > > > kable with kableExtra to make tables.<br>
          > > > > The input to kable are R data frames, or
          data.tables, which are the<br>
          > > > > result of model fitting and related
          calculations.<br>
          > > > > But we like to put mathematical
          expressions in selected cells of<br>
          > > tables,<br>
          > > > > which is so easy with LYX tables, and we
          currently<br>
          > > > > have to make the data entry into LYX by
          hand from data tables and<br>
          > > > > data.tables in order to make use of that
          feature.<br>
          > > > > So it would be great if we could import R
          data tables and data.tables<br>
          > > > > into LYX tables, rather than using the
          kable/kableExtra<br>
          > > > > solution for our tables  (maybe I didn't
          make that clear in my earlier<br>
          > > > > email).  Then we would probably would drop
          use of<br>
          > > > > kable/kableExtra.<br>
          > > ><br>
          > > > So you want to import as .tex the result of R
          processing. This can be<br>
          > > done<br>
          > > > via "Paste from LaTeX". What would be missing
          for your intended usage?<br>
          > ><br>
          > > From what I understand, they would like to import a
          .Rds file without<br>
          > > having to manually convert it to LaTeX.<br>
          > ><br>
          > <br>
          > Scott,<br>
          > <br>
          > Definitely correct on the "without" part.  But we want to
          directly import<br>
          > an R object<br>
          > of class data.frame or data.table into an LYX table.<br>
          > <br>
          > If we have to export such an object first, we would
          typically export it to<br>
          > an .Rda object.<br>
          > But it would be far more convenient to not have to do
          that.<br>
          <br>
          Thanks for the clarification, Doug. It might help us to have a
          complete,<br>
          simple, example to play with. Can you give us the .lyx file
          and R<br>
          code/file? To make things perfectly clear to us, it might help
          to give<br>
          us a "before" version of the .lyx file and an "after" version
          of the<br>
          .lyx file. To create the "after" version you would have to do
          the steps<br>
          manually, but by seeing it we could make sure we understand
          what you<br>
          want to automate and what you expect the result to be.<br>
          <br>
          Thanks for your patience,<br>
          <br>
          Scott<br>
        </blockquote>
      </div>
      <br clear="all">
      <br>
      -- <br>
      <div dir="ltr" class="gmail_signature">
        <div dir="ltr">R. Douglas Martin
          <div>Professor Emeritus in Applied Mathematics and Statistics</div>
          <div>Founder and Former Director of MS-CFRM Program</div>
          <div><a href="http://depts.washington.edu/compfin/"
              target="_blank" moz-do-not-send="true">depts.washington.edu/compfin/</a></div>
          <div>University of Washington</div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
    </blockquote>
    Doug,<br>
    <br>
    If I am understanding your example correctly, you actually redo the
    R calculations each time you compile the LyX document. Is that a
    desired feature, or would you be just as happy running the R code
    once and parking the generated table in the LyX document? I ask
    because elsewhere in the thread I pointed out (in a reply to Riki)
    that one can use a custom R function (which you could set up to load
    by default whenever you crank up R) to convert a data frame or table
    to LaTeX and copy the LaTeX code to the clipboard. After that, all
    you have to do is paste it into your open LyX document using the
    correct LyX command, and it goes in as a table.<br>
    <br>
    Paul<br>
    <br>
    <div class="moz-signature">-- <br>
      Paul A. Rubin, Professor Emeritus<br>
      The Eli Broad College of Business<br>
      Michigan State University<br>
      Email: <a href="mailto:rubin@msu.edu">rubin@msu.edu</a><br>
      Home page: <a href="https://rubin.msu.domains/">https://rubin.msu.domains/</a><br>
    </div>
  </body>
</html>