我有这样的乳胶表生成代码示例
df<-data.frame(name=rep(letters[1:7],each=24),salary=runif(24*7,100,200))
lst<-tapply(df$salary,df$name,matrix,nrow=4,byrow=T)
xlst<-lapply(lst,xtable)
Run Code Online (Sandbox Code Playgroud)
现在我想在每个表中的每一行之后自动引入\ hdashline,并且在R代码之间的表之间还有一个\ vspace {2em} Wat我试过这个
for(i in seq_along(lst)){
addtorow[i] <- list(pos = list(seq_len(nrow(lst[[i]])-1)),
command = "\\hdashline \n")
}
Run Code Online (Sandbox Code Playgroud)
扫描更改我需要进行循环..它适用于我申请单个表但不能在for循环中工作...任何帮助非常感谢...
我一直在尝试创建一个包含类似中断的标题的表.我在这里并不是太野心勃勃,并不关心我是否只是打破了很长的字符串或者只是一个两行标题.
dat <- matrix(round(rnorm(9, 20, 10)), 3, 3)
colnames(dat) <- c("some very long colname","short","another toooooooolong colname")
require(xtable)
m <- xtable(dat)
print(m,
floating=FALSE,
hline.after=NULL,
size="\\footnotesize",
tabular.environment="tabular",
add.to.row=list(pos=list(-1,0,nrow(m),0
),
command=c('\\toprule ',
'\\midrule ',
'\\bottomrule',
'\\\\ \\rowcolor[gray]{.9}'
)
)
)
Run Code Online (Sandbox Code Playgroud)
有没有办法打破标题,因为我的表已不适合页面,虽然我landscape已经使用了.一些sanitize.rownames基于的技巧?摆弄\shortstack但无法让它去......
我想组合两个数据帧的表,并希望将该表导出到latex.我想要创建的表如下所示.请注意,下表是使用excel创建的.

从RI中的xtable可以导出两个单独的站的表.获得以下两个站点T1和T2.如何组合两个站的输出以获得上述所需的输出?
T1站:
> stT1
Observed-modeled |observed-modeled|
Min. -1.5360000 0.0001891
1st Qu. 0.0002512 0.1633000
Median 0.3593000 0.5390000
Mean 0.8554000 1.0020000
3rd Qu. 1.6470000 1.6470000
Max. 5.5370000 5.5370000
> dput(stT1)
structure(list(`Observed-modeled` = c(-1.536, 0.0002512, 0.3593,
0.8554, 1.647, 5.537), `|observed-modeled|` = c(0.0001891, 0.1633,
0.539, 1.002, 1.647, 5.537)), .Names = c("Observed-modeled",
"|observed-modeled|"), row.names = c("Min.", "1st Qu.", "Median",
"Mean", "3rd Qu.", "Max."), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
T2站:
> stT2
Observed-modeled |observed-modeled|
Min. -2.3740 0.001259
1st Qu. -1.2280 0.674700
Median -0.6202 1.101000
Mean -0.2094 1.085000 …Run Code Online (Sandbox Code Playgroud) 请考虑以下MWE
library(xtable)
DF <- as.data.frame(UCBAdmissions)
print(xtable(DF, align="p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}"), sanitize.text.function = function(x){x},
table.placement="!htp", include.rownames=FALSE,
tabular.environment='longtable',floating=FALSE)
Run Code Online (Sandbox Code Playgroud)
我想设置我longtable喜欢的对齐方式
\begin{longtable}{p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}}
Run Code Online (Sandbox Code Playgroud)
当我试图将参数传递给xtable我得到的对象时
Warning message:
In .alignStringToVector(value) : Nonstandard alignments in align string
Error in print(xtable(DF, align = "p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}"), :
error in evaluating the argument 'x' in selecting a method for function 'print': Error in `align<-.xtable`(`*tmp*`, value = "p{0.4\textwidth}|p{0.15\textwidth} p{0.15\textwidth} p{0.15\textwidth}") :
"align" must have length equal to 5 ( ncol(x) + 1 )
Run Code Online (Sandbox Code Playgroud)
我明白我应该为第5列添加对齐(如何?)但我也不理解错误消息.我应该清理字符串吗?
假设我想使用xtable并排打印HTML表.我尝试在.Rmd文件中执行此操作:
<table border = 1>
<tr>
<td>
`r functionThatPrintsAnHTMLTableUsingxtable`
</td>
<td>
`r functionThatPrintsAnotherHTMLTableUsingxtable`
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
没有骰子.我究竟做错了什么?谢谢.
如何在rmarkdown生成的pdf_document中获取我的表浮动的标题?
运用
output:
pdf_document:
fig_caption: true
Run Code Online (Sandbox Code Playgroud)
和
```{r, fig.cap='a caption'}
myplot
```
Run Code Online (Sandbox Code Playgroud)
使用myplot和指定的标题生成浮动数字.
如何使用xtable生成的表实现相同的功能?
```{r, results='asis', fig.cap='table caption'}
print(xtable(table), comment = FALSE)
```
Run Code Online (Sandbox Code Playgroud)
我曾尝试在print.xtable中使用floating.environment ='figure',但无济于事.
我想要一个包含可变数量表的sweave文档.我认为下面的例子可行,但事实并非如此.我想循环遍历列表foo并打印每个元素作为它自己的表.
%
\documentclass[a4paper]{article}
\usepackage[OT1]{fontenc}
\usepackage{longtable}
\usepackage{geometry}
\usepackage{Sweave}
\geometry{left=1.25in, right=1.25in, top=1in, bottom=1in}
\listfiles
\begin{document}
<<label=start, echo=FALSE, include=FALSE>>=
startt<-proc.time()[3]
library(RODBC)
library(psych)
library(xtable)
library(plyr)
library(ggplot2)
options(width=80)
#Produce some example data, here I'm creating some dummy dataframes and putting them in a list
foo<-list()
foo[[1]]<-data.frame(GRP=c(rep("AA",10), rep("Aa",10), rep("aa",10)), X1=rnorm(30), X2=rnorm(30,5,2))
foo[[2]]<-data.frame(GRP=c(rep("BB",10), rep("bB",10), rep("BB",10)), X1=rnorm(30), X2=rnorm(30,5,2))
foo[[3]]<-data.frame(GRP=c(rep("CC",12), rep("cc",18)), X1=rnorm(30), X2=rnorm(30,5,2))
foo[[4]]<-data.frame(GRP=c(rep("DD",10), rep("Dd",10), rep("dd",10)), X1=rnorm(30), X2=rnorm(30,5,2))
@
\title{Docuemnt to test putting a variable number of tables into a sweave Document}
\author{"Paul Hurley"}
\maketitle
\section{Text}
This document was …Run Code Online (Sandbox Code Playgroud) 我可以控制的add.to.row命令xtable放置一个\footnote{}在LaTeX表输出头?
这是我走了多远.(我想找到一个使用xtable而不是'Hmisc' 的解决方案)
require(xtable)
x <- matrix(rnorm(60), ncol = 10)
x.big <- xtable(x,label='tabbig', caption='Example of longtable')
names(x.big) <- LETTERS[1:10]
print(x.big,tabular.environment='longtable',floating=FALSE,
add.to.row = list(pos = list(seq(1,nrow(x.big), by = 2), 0, 1),
command = c("\\rowcolor[gray]{.95} ", "\\hline \\endhead ",
"\\footnote{This is the first footnote that I would like to have
in the headder next to `I'.}") ) )
Run Code Online (Sandbox Code Playgroud)
然后我在小乳胶文件中使用输出.像这样:
\documentclass{article}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage[landscape]{geometry}
\begin{document}
I
\vspace{100 mm}
% latex table generated in …Run Code Online (Sandbox Code Playgroud) 我有一个包含超链接的数据框,我希望将其作为可点击链接使用Sweave.我知道xtable,但不知道如何使用它来处理数据帧的内容作为LaTeX命令.
我试图在ASCII表中显示极小的数字(<1E-12).(相信我,我找不到任何替代方案.)到目前为止,我已经尝试过stargazer和xtable.它们似乎都不起作用.我可以用HTML中的xtable以科学记数法显示数字,但不能显示ASCII.Stargazer似乎无法用科学记数法显示数字.以下是一个例子:
library(stargazer)
example <- data.frame(parameter = letters, value = runif(26, min = 1E-14, max = 5E-14))
stargazer(example, summary = F, type = "text", digits = NA)
Run Code Online (Sandbox Code Playgroud)
即使我将数字选项设置为NA,所有值都被截断为0,这应该保留所有内容.任何帮助真的很感激!谢谢!