Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hmisc::latex函数在同时使用cellTexCmds和cgroup参数时无法正常工作(较新的R/package版本)_R_Latex_Hmisc - Fatal编程技术网

Hmisc::latex函数在同时使用cellTexCmds和cgroup参数时无法正常工作(较新的R/package版本)

Hmisc::latex函数在同时使用cellTexCmds和cgroup参数时无法正常工作(较新的R/package版本),r,latex,hmisc,R,Latex,Hmisc,我正在尝试使用Hmisc包中的LaTeX函数为LaTeX格式化一个表,使用cellTexCmds参数格式化特定单元格,使用cgroup/n.cgroup参数生成标题分组 我所期望的行为发生在R 2.15.0中的Hmisc3.12-2版: > table.data<-data.frame(a=1:3,b=4:6,c=3:5,d=8:10) > tex.matrix<-matrix(rep("",12),nrow=3) > tex.matrix[1,3]<-"\\

我正在尝试使用
Hmisc
包中的
LaTeX
函数为LaTeX格式化一个表,使用
cellTexCmds
参数格式化特定单元格,使用
cgroup
/
n.cgroup
参数生成标题分组

我所期望的行为发生在R 2.15.0中的
Hmisc
3.12-2版:

> table.data<-data.frame(a=1:3,b=4:6,c=3:5,d=8:10)
> tex.matrix<-matrix(rep("",12),nrow=3)
> tex.matrix[1,3]<-"\\color{red}"
> latex(table.data,cgroup=c("group1","group2"),n.cgroup=c(2,2),cellTexCmds=tex.matrix,file="")
% latex.default(table.data, cgroup = c("group1", "group2"), n.cgroup = c(2,      2), cellTexCmds = tex.matrix, file = "") 
%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrrcrr}
\hline\hline
\multicolumn{1}{l}{\bfseries table.data}&\multicolumn{2}{c}{\bfseries group1}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries group2}\tabularnewline
\cline{2-3} \cline{5-6}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{a}&\multicolumn{1}{c}{b}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{c}&\multicolumn{1}{c}{d}\tabularnewline
\hline
   1&   $1$&   $4$&   &\\color{red}   $3$&   $ 8$\tabularnewline
   2&   $2$&   $5$&   &   $4$&   $ 9$\tabularnewline
   3&   $3$&   $6$&   &   $5$&   $10$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}

额外的格式现在位于单元格(1,4)中。如果没有主标题分组的
cgroup
n.cgroup
参数,则在这两个版本中都可以正常工作。这仅仅是新版本软件包中的一个bug,还是有一些变化意味着这是正确的行为?如果是,我如何获得预期的结果(我在文档中看不到任何表明有任何变化的内容)

Hi!我已经用R3.4.2测试过了,我无法重现这个问题!我已经用R3.4.2进行了测试,我无法重现这个问题
> table.data<-data.frame(a=1:3,b=4:6,c=3:5,d=8:10)
> tex.matrix<-matrix(rep("",12),nrow=3)
> tex.matrix[1,3]<-"\\color{red}"
> latex(table.data,cgroup=c("group1","group2"),n.cgroup=c(2,2),cellTexCmds=tex.matrix,file="")
%latex.default(table.data, cgroup = c("group1", "group2"), n.cgroup = c(2,     2), cellTexCmds = tex.matrix, file = "")%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrrcrr}
\hline\hline
\multicolumn{1}{l}{\bfseries table.data}&\multicolumn{2}{c}{\bfseries group1}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries group2}\tabularnewline
\cline{2-3} \cline{5-6}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{a}&\multicolumn{1}{c}{b}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{c}&\multicolumn{1}{c}{d}\tabularnewline
\hline
   1&   $1$&   $4$&   &   $3$&\\color{red}   $ 8$\tabularnewline
   2&   $2$&   $5$&   &   $4$&   $ 9$\tabularnewline
   3&   $3$&   $6$&   &   $5$&   $10$\tabularnewline
\hline
\end{tabular}\end{center}

\end{table}