标签: hmisc

Hmisc :: latex不打印带有表格对象的标题

首先,我会告诉你我正在尝试做大事,以防我错了.我有一个嵌套的表,我希望使用knitr将其作为LaTX表放在RStudio中.我很好,直到我尝试添加标题.我在tables插图(LINK)中尝试了第9页上的示例.

它没有标题,但当我添加标题时,它没有.它也适用于非表格对象.有趣的是,它latex.default可以工作,但会导致RStudio/knitr的编译PDF中的错误,并且latex无论如何都会从我读到的内容中调用; 加上桌子不再适当地四舍五入.我尝试过,latexTabular但这也不合适.

library(Hmisc); library(tables)
latex(head(mtcars), file="", caption="de")   #works

x <- tabular( (Species + 1) ~ (n=1) + Format(digits=2)*
         (Sepal.Length + Sepal.Width)*(mean + sd), data=iris )

latex(x, file="", caption="de") #no caption :(
Run Code Online (Sandbox Code Playgroud)

理想情况下,我希望能够\caption{de}输出,但无法弄清楚我哪里出错了.

如果它在这里是有用的输入和输出:

> latex(x, file="", caption="de", label="tab1") 
\begin{tabular}{lccccc}
\hline
 &  & \multicolumn{2}{c}{Sepal.Length} & \multicolumn{2}{c}{Sepal.Width} \\ 
Species  & n & mean & sd & mean & sd \\ 
\hline
setosa  & $\phantom{0}50$ & $5.01$ & $0.35$ & …
Run Code Online (Sandbox Code Playgroud)

latex r tabular hmisc

6
推荐指数
2
解决办法
1137
查看次数

从Hmisc包中的latex()创建的表是水平左对齐而不是在pdf文档中以水平方式居中

使用R-studio和Knitr创建一个pdf我无法让这些表格以焦点为中心.从下面的例子可以看出,使用xtable()可以正常工作,但latex() - tabels都是左对齐的.据我了解Hmisc文档,从latex()创建的表应该是自动地进行水平居中,但我必须做错事.

\documentclass{article}

\begin{document}

<<>>=
library(Hmisc)
library(tables)
library(xtable)
@


The tables are all left-aligned:
<<results='asis'>>=
latex(    tabular( (Species + 1) ~ (n=1) + Format(digits=2)*(Sepal.Length + Sepal.Width)*(mean + sd), data=iris )  )
@

<<results='asis'>>=
latex(    tabular( (Species + 1) ~ (n=1) + Format(digits=2)*(Sepal.Length + Sepal.Width)*(mean + sd), data=iris ),center="center"   )
@

<<results='asis'>>=
latex(    tabular( (Species + 1) ~ (n=1) + Format(digits=2)*(Sepal.Length + Sepal.Width)*(mean + sd), data=iris ),center="centering"   )
@


I have tried to use the fig.align option, but it does …
Run Code Online (Sandbox Code Playgroud)

latex r hmisc

6
推荐指数
1
解决办法
719
查看次数

乳胶(描述(...))是否在MiKTeX的编织下工作?

当我创建一个文件describe.Rnw如下:

\documentclass{article}

\begin{document}

<<results='asis'>>=
require(Hmisc)
latex(describe(cars), file="")
@


\end{document}
Run Code Online (Sandbox Code Playgroud)

并尝试用它编译它

library(knitr)
knit2pdf("describe.Rnw")
Run Code Online (Sandbox Code Playgroud)

我收到错误消息,提示乳胶(describe())组合创建的乳胶有语法错误:

LaTeX errors:
P:/r/ellisp/test/describe.tex:65: LaTeX Error: Environment spacing undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help
Your command was ignored.
P:/r/ellisp/test/describe.tex:131: LaTeX Error: \begin{document} ended by \end{
spacing}.

See the LaTeX manual or LaTeX Companion for explanation.
Run Code Online (Sandbox Code Playgroud)

我可以看到它生成的胶乳,粘贴在下面 - 可能是因为线间距混淆解析的错误?我的整个设置是新的(实际上是在测试模式下),虽然我已经成功编译了文档,但我还是knitr的新手,但我不知道我的设置是否也有问题.我的第一个问题是,我做错了什么或这是一个更普遍的问题?

> latex(describe(cars), file="")
\begin{spacing}{0.7}
\begin{center}\textbf{ cars \\ 2 Variables~~~~~ 50 ~Observations}\end{center}
\smallskip\hrule\smallskip{\small
\vbox{\noindent\textbf{speed}

{\smaller
\begin{tabular}{ rrrrrrrrrrr }
n&missing&unique&Mean&.05&.10&.25&.50&.75&.90&.95 \\
50&0&19&15.4& …
Run Code Online (Sandbox Code Playgroud)

latex miktex knitr hmisc

5
推荐指数
1
解决办法
760
查看次数

如何在R中的Hmisc中将注释附加到乳胶表中?

一种不雅的方式就是用注释文本添加一行tex代码.

但是latex,Hmisc在R 中使用包的功能有更原生的方式做笔记吗?

latex r hmisc

5
推荐指数
1
解决办法
480
查看次数

如何标记变量、数据框列(全名+单位),以便绘图、xtable 等自动使用这些信息?

我刚刚意识到 Hmisc 包中的标签功能。然而,据我所知,这个函数并没有解决我的问题,因为轴标签仍然需要手动指定为xlab=label(var).

我也没有看到任何生成漂亮表格(xtable)的解决方案。是否有任何我不知道的软件包提供此类功能?总之,我想做以下事情:

  • 将标签和单位附加到变量、列:label(wght) <- weight; unit(var) <- 'kg'
  • 以良好的方式打印它们,例如:wght <- c(20, 30); printnice(mean(wght)) -> '25 kg'
  • 制作绘图,xtable 自动使用这些“好”标签

label r units-of-measurement xtable hmisc

5
推荐指数
0
解决办法
468
查看次数

ggplot2 stat_summary mean_sdl 与平均值 +/- sd 不同

我不确定为什么 ggplot2 中的 mean_sdl 函数(来自 Hmisc)生成的误差线比手动生成的误差线宽得多并绘制均值 + sd 和均值 - sd。我的代码:

library(drc)
library(tidyverse)

test_dataset <- 
  structure(
    list(
      X = c(1e-10, 1e-08, 3e-08, 1e-07, 3e-07, 1e-06, 3e-06, 1e-05, 3e-05, 1e-04, 3e-04),
      AY1 = c(0, 11, 125, 190, 258, 322, 354, 348, NA, 412, NA),
      AY2 = c(3, 33, 141, 218, 289, 353, 359, 298, NA, 378, NA),
      AY3 = c(2, 25, 160, 196, 345, 328, 369, 372, NA, 399, NA),
      BY1 = c(3, NA, 11, 52, 80, 171, 289, 272, 359, …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 hmisc drc

5
推荐指数
1
解决办法
8755
查看次数

data.table:lapply一个具有多列输出的函数

我正在使用smean.cl.normalHmisc包中的一个函数,该函数返回一个包含3个值的向量:均值和低位和高位CI.当我在data.table2组使用它时,我获得2列和6行.有没有办法获得结果,两行对应2组,每个函数的输出分别列,即均值和CI?

require(Hmisc)
require(data.table)

dt = data.table(x = rnorm(100),
                gr = rep(c('A', 'B'), each = 50))

dt[, lapply(.SD, smean.cl.normal), by = gr, .SDcols = "x"]
Run Code Online (Sandbox Code Playgroud)

输出:

   gr           x
1:  A -0.07916335
2:  A -0.33656667
3:  A  0.17823998
4:  B -0.02745333
5:  B -0.32950607
6:  B  0.27459941
Run Code Online (Sandbox Code Playgroud)

所需的输出:

   gr        Mean         Lower         Upper
1:  A -0.07916335   -0.33656667    0.17823998
2:  B -0.02745333   -0.32950607    0.27459941
Run Code Online (Sandbox Code Playgroud)

r hmisc data.table

5
推荐指数
1
解决办法
657
查看次数

corrplot 错误:参数暗示行数不同

我正在尝试使用 rcorr 函数(hmisc 包)和 corrplot 生成相关图

library("Hmisc")
library("corrplot")
res2<-rcorr(as.matrix(A), type = "spearman")
corrplot(res2$r, order="AOE", 
         p.mat = res2$P, sig.level = 0.05, insig = "blank")
Run Code Online (Sandbox Code Playgroud)

我得到了相关图,但出现错误消息:“data.frame(..., check.names = FALSE) 中的错误:参数暗示不同的行数:169, 156”我看不出 rcorr 有任何问题输出。谁能帮我?谢谢!

hmisc r-corrplot

5
推荐指数
1
解决办法
1430
查看次数

ggplot2有两个data.frames,不知道如何处理class uneval的数据

我是R的新手,不知道如何使用ggplot2绘制两个data.frames.我收到以下错误消息:Error: ggplot2 doesn't know how to deal with data of class uneval

如何将我的数据与基础世界地图放在一起?

这是我的代码:

require(Hmisc)
require(mapproj)
require(ggplot2)
require(rgdal)
require(maptools)
require(sp)
require(cshapes)
gpclibPermit()

world <- cshp(date=as.Date("2008-1-1"))
world.points <- fortify(world, region='COWCODE')
p <- ggplot(world.points, aes(long,lat,group=group)) + geom_polygon()

dat <- mdb.get("CLIWOC15_2000.mdb") # you can get the data from here: http://pendientedemigracion.ucm.es/info/cliwoc/cliwoc15.htm

tmp <- dat$CLIWOC15[,c("Lon3","Lat3")]

ggplot(world.points,aes(long,lat,group=group))
+geom_polygon()
+geom_point()
+geom_histogram(tmp,aes(Lon3,Lat3),alpha=0.01,size=1)
+coord_map()+ylim(-90,90)
Run Code Online (Sandbox Code Playgroud)

r ggplot2 r-maptools rgdal hmisc

4
推荐指数
1
解决办法
2万
查看次数

如何使用ggplot2,reshape2和Hmisc在R中进行三角形热图?

我需要帮助在R中使用ggplot2,reshape2和Hmisc进行三角形热图,因为我需要在图上显示r和P值.

我试过cordata[lower.tri(c),]在很多地方插入它并没有帮助.我也试过使用不同的方法,但他们没有显示p值是一个rho,我需要!我试过在这里和谷歌上搜索"Hmisc + triangle + heatmap"并且发现没有任何效果.

这是原始数据,从excel表导入:df

# A tibble: 8 x 7
     Urine   Glucose    Soil         LB Gluconate   River    Colon
     <dbl>     <dbl>   <dbl>      <dbl>     <dbl>   <dbl>    <dbl>
1  3222500 377750000 7847250  410000000   3252500 3900000 29800000
2  3667500 187000000 3937500  612000000   5250000 4057500 11075000
3  8362500 196250000 6207500  491000000   2417500 2185000  9725000
4 75700000 513000000 2909750 1415000000   3990000 3405000       NA
5  4485000 141250000 7241000  658750000   3742500 3470000  6695000
6  1947500 235000000 3277500  528500000   7045000 1897500 25475000
7  4130000 202500000 …
Run Code Online (Sandbox Code Playgroud)

r heatmap ggplot2 correlation hmisc

4
推荐指数
2
解决办法
494
查看次数