Oh of course! It's obvious when you say that. As I say, I just don't have a mind-map of LyX/LateX yet.
Thanks for all the help. ________________________________ From: Liviu Andronic <landronim...@gmail.com> To: John Kane <jrkrid...@yahoo.ca> Cc: Users LyX <lyx-users@lists.lyx.org> Sent: Monday, May 13, 2013 10:18:26 AM Subject: Re: Problem producing tables with knitr and xtable On Mon, May 13, 2013 at 4:04 PM, John Kane <jrkrid...@yahoo.ca> wrote: > I finally got it. It was the xtable placed within the float that was causing > the table error. Once I had realised that and got rid of the APA6 issue > which was due to the fact that APA6 requires a title then it was fine. > Thanks for all the help. > Great. > This is working fine > <<atable,results="asis", echo=FALSE>>= > library(xtable) > data(tli) > tli.table <- xtable(tli[1:20, ], caption = "An xtable example", label = > "tab:A table") > digits(tli.table)[c(2, 6)] <- 0 > print(tli.table, caption.placement="top") > @ > > One question though, you say "Use print.xtable(...,floating=F) to avoid > this. Do you mean that if I want to place it with a LyX float that the code > below should work? Currently it gives an error. > <<atable,results="asis", echo=FALSE>>= > library(xtable) > data(tli) > tli.table <- xtable(tli[1:20, ], caption = "An xtable example", label = > "tab:A table") > digits(tli.table)[c(2, 6)] <- 0 > print(tli.table, caption.placement="top", floating=FALSE) > @ > I suspect that if you want floating=FALSE (and put it into a float within LyX), then you should avoid caption = "An xtable example" and caption.placement="top". Setting either of these arguments could automatically force floating=T. (The help page seems silent on this.) If I remember, the first .lyx file that I sent you worked exactly as you want here. Liviu > ________________________________ > From: Liviu Andronic <landronim...@gmail.com> > To: John Kane <jrkrid...@yahoo.ca> > Cc: Users LyX <lyx-users@lists.lyx.org> > Sent: Friday, May 10, 2013 4:23:00 PM > > Subject: Re: Problem producing tables with knitr and xtable > > On Fri, May 10, 2013 at 8:55 PM, John Kane <jrkrid...@yahoo.ca> wrote: >> I have been playing with LyX and knitr. I have had no problem generating >> figures generally using ggplot2 I cannot get LyX to generate a table with >> knitr and xtable. >> > See attached. Two issues: > - You need to use chunk option results="asis" (similar to results=tex > for Sweave) > - By default xtable() outputs the table in a floating environment; it > makes little sense to put that in a table float. Use print.xtable(..., > floating=F) to avoid this. > > Liviu > > >> The file table.knitr one is my last attempt to generate a table. Not a >> success though there is something there. table.kniter2.lyx is a >> successful >> example of my running the same code in R and then just cutting and pasting >> the resulting LaTeX code (minus the \begin{table}[ht] & \end{table} of >> course. >> >> Can anyone give me some pointers as to what I am doing wrong? I seem to >> have spent about 2 hours trying to find some useful examples without much >> success. >> >> Thanks. > > > > -- > Do you know how to read? > http://www.alienetworks.com/srtest.cfm > http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader > Do you know how to write? > http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail > > -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail