r - Slidify 中编号列表的延续

标签 r r-markdown slidify

如何在 slidify 中将编号列表延续到新幻灯片上?

我的代码如下所示:

---
title       : Another Introductory R Session
subtitle    : 
author      : Christopher Meaney
job         : Biostatistician, University of Toronto
framework   : io2012        # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js  # {highlight.js, prettify, highlight}
hitheme     : tomorrow      # 
widgets     : [mathjax]            # {mathjax, quiz, bootstrap}
mode        : selfcontained # {standalone, draft}

--- .nobackground 

1. Item 1
2. Item 2
3. Item 3
4. Item 4

--- .nobackground

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
  * Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`

我希望第二张幻灯片上的列表以 5 开头。项目 5。6。项目 6...等等。但是列表编号被重置为 1. Item 5. 2. Item 6 等等。

最佳答案

可能最简单的方法是在幻灯片内容后添加一些 javascript:

--- .nobackground #foo

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
* Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`


<script>
$("#foo ol").attr('start', 5)
</script>

---

其他方法:

你可以只使用 html
---
<ol start="5">
    <li>Item 5</li>
    <li>Item 6</li>
</ol>
---

slidify example

或者你可以求助于 CSS:
--- .nobackground #foo

5. Create the following matrix `mat <- matrix(1:9,ncol=3)`.
  * How many ways can you think of to get the column means of `mat`? 
  * Same idea with row means.

6. In matrix notation the OLS/MLE solution for the regression coeffiicients of a linear regression model can be expressed as:

$$ \hat{\boldsymbol\beta} = (\mathbf{X}^{\rm T}\mathbf{X})^{-1} \mathbf{X}^{\rm T}\mathbf{y} $$

* Using the cars dataset investigate the relationship between distance (response variable) as a function of speed (independent variable).
* Create the vector `y` and the design matrix `X`. Dont forget the leading column vector of 1's. Using all of R's fancy matrix algebra functions estimate the $\hat{\boldsymbol\beta}$ vector. 
* Compare your matrix algebra approach with the following code: `lm(dist~speed,data=cars)`

---

现在在你的assets/css中添加一个styles.css
#foo OL {
  counter-reset: item 4;
}
#foo OL>LI { display: block }
#foo OL>LI:before {
        content: counter(item) ". ";
        counter-increment: item;
        display:block;
        }

或者,您可以在幻灯片中将样式作为 HTML 插入
<style>
#foo OL {
  counter-reset: item 4;
}
#foo OL>LI { display: block }
#foo OL>LI:before {
      content: counter(item) ". ";
        counter-increment: item;
        display:block;
        }
</style>

enter image description here

关于r - Slidify 中编号列表的延续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23859227/

相关文章:

r -/usr/bin/Rscript : Argument list too long

r - 如何在 Shiny 中包含带有反应式 MathJax 元素的 html 代码?

r - 从 R 笔记本输出 Rmarkdown

r - 使用 dbSendQuery 在数据库上创建表时避免警告消息 “There is a result object still in use”

r - 使用 pdftools 包和 png 包将 pdf 转换为 png 图像给出不完整的 png

r - 来自 R 脚本的循环 tbl_regression 不为 rmarkdown::render 打印

html - Slidify - 如何自定义幻灯片背景?

css - 在 rCharts/slidify/nvd3 中设置图表区域背景颜色

r - 通过电子邮件或其他安全方法发送/共享敏感的 R slidify 演示文稿

r - 使用 mutate_if 和 force_tz 更改所有时间戳的时区