我想在 slidify 中将 data.frame 的内容显示为表格。我知道如何使用 ascii 库从 data.frames 创建 Markdown 表,但是当我尝试将它与 slidify 一起使用时,我没有看到输出 html 中的表,而是看到了一堆关于 ascii 表内部结构的信息。
那么如何在 slidify 中打印例如 head(some.data.frame)?
编辑:
事实上,我想在 CRAN 任务视图中显示一个视图表,现在我在 Markdown 中手动输入了该表:
Views | Content
--------|--------
Bayesian| Bayesian Inference
ChemPhys| Chemometrics and Computational Physics
ClinicalTrials| Clinical Trial Design, Monitoring, and Analysis
我想从ctv
包中自动创建这个表。我已经在 data.frame 中收集了我需要的信息:
library(ctv)
list.of.views <- available.views()
X <- data.frame(View=NA,Description=NA)
for(i in 1:length(list.of.views))
{
X[i,1] <- list.of.views[[i]]$name
X[i,2] <- list.of.views[[i]]$topic
}
head(X)
这导致
View Description
1 Bayesian Bayesian Inference
2 ChemPhys Chemometrics and Computational Physics
3 ClinicalTrials Clinical Trial Design, Monitoring, and Analysis
4 Cluster Cluster Analysis & Finite Mixture Models
5 DifferentialEquations Differential Equations
6 Distributions Probability Distributions
我使用ascii
包进行降价
library(ascii)
print(ascii(X[1:6,1:2]), type = 'pandoc')
在 R 终端中显示了这一点:
**View** **Description**
--- ----------------------- -------------------------------------------------
1 Bayesian Bayesian Inference
2 ChemPhys Chemometrics and Computational Physics
3 ClinicalTrials Clinical Trial Design, Monitoring, and Analysis
4 Cluster Cluster Analysis & Finite Mixture Models
5 DifferentialEquations Differential Equations
6 Distributions Probability Distributions
--- ----------------------- -------------------------------------------------
Warning messages:
1: In rep(rownames, length = nrow(x)) :
'x' is NULL so the result will be NULL
2: In rep(colnames, length = ncol(x)) :
'x' is NULL so the result will be NULL
但是当我的文件和它print
的代码块中的最后一行时,我在幻灯片中看到以下内容:Rmd
slidify
## <S4 Type Object>
## attr(,".xData")
## <environment: 0x03b904d8>
## attr(,"class")
## [1] "asciiTable"
## attr(,"class")attr(,"package")
## [1] "ascii"