Somehow my reply from the iPad Newsreader got lost.

Why not include R Chunks generating tables and/or graphics at PDF
generation in the LyX file using the knitr module?

After a chunk with something like (for MySQL/MariaDB)

        suppressPackageStartupMessages(library(RMySQL))
        library(RMySQL)
        drv = dbDriver("MySQL")
        con = dbConnect(drv, host = "dbh.sub.TLD",
                dbname = "db",
                user = "usr",
                password = "pssw"
        )
        allvars = data.table(dbGetQuery(con, statement = "select * from table"))

put into a chunk (inside a float) something like:

        alltable = xtable(allvars,
                align = "|r|r|rrr|rrr|rr|",
                label = 'alltable',
                caption = 'THis is a Caption',
                digits = c(0,2,2,2,2,2,2,2,2,2)
        )
        print(alltable,
                only.contents = T,
                hline.after=c(0:nrow(allvars)),
                include.colnames = F,
                include.rownames = F,
                floating = F
        )

Put ERT before and after the chunk (inside the float) sorting out the
headers and footers.

Once having figures out the syntax for the exat SQL and xtable, this is
certainly more efficient than any manual intervention, however little
:-)-O.

el

On 2018-10-30 22:56 , Rich Shepard wrote:
> On Tue, 30 Oct 2018, Baris Erkus wrote:
> 
>> Just a minor fix:
>>
>> 1. Replace all the "|" with the tab character with a text editor.
>> 2. Select the portion you want to paste.
>> 2a. Copy to clipboard.
>> 3. Go to the first cell in Lyx.
>> 4. Edit > Paste Special > Plain Text.
>> 5. Table row and columns numbers should be compatible with the text file
>> contents...
> 
> Baris,
> 
>   The two critical pieces I missed before were steps 1 and 4.  Using
>   tabs and paste special did the job.
> 
>   Many of the tables I use in a lyx document are generated by sql
>   extraction from a database table, an R function, or cleaned data in
>   emacs.  While I've tried bulk copying without using tabs and paste
>   special I did not get the results needed.
> 
>   Many thanks for the lesson.
> 
> Best regards,
> 
> Rich
> 

Reply via email to