In order to be able to use a label tab:my_title
, I would like to place a table generated by xtable in a Lyx table float, but I cannot get a table to be generated inside the float. This chunk produces correct output in Lyx:
<<cars, echo=FALSE, warning=FALSE, results='asis', message=FALSE>>=
library(xtable)
print.xtable(xtable(head(cars), digits = 0), include.rownames=FALSE,
type = "latex", floating=FALSE)
@
But when I place the above chunk in a table float, Lyx doesn't generate an output. I specified floating=FALSE so that xtable doesn't produce a floating environment for the table.
An answer to a similar question looks like a hack. I would prefer to properly insert the xtable output in a float.
Minimal lyx file as requested by @scottkosty
#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\use_default_options true
\begin_modules
knitr
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
<<cars, echo=FALSE, warning=FALSE, results='asis', message=FALSE>>=
\end_layout
\begin_layout Plain Layout
library(xtable)
\end_layout
\begin_layout Plain Layout
print.xtable(xtable(head(cars), digits = 0), include.rownames=FALSE,
\end_layout
\begin_layout Plain Layout
type = "latex", floating=FALSE)
\end_layout
\begin_layout Plain Layout
@
\end_layout
\end_inset
\end_layout
\end_body
\end_document