Created
June 1, 2012 22:35
-
-
Save kohske/2855525 to your computer and use it in GitHub Desktop.
Rmd for slidify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r setup, echo = FALSE} | |
opts_knit$set(out.format = 'html') | |
opts_chunk$set(highlight = TRUE) | |
``` | |
# Slidify | |
超簡単スライド作成 | |
@kohske | |
--- | |
### マークダウンからスライドを作成しましょう | |
このスライドの元になってるRmdはこちら | |
https://gist.github.com/2855525 | |
--- | |
### 手軽に資料を作りましょう | |
- markdown!! | |
- knitr!! | |
- slidify | |
やばいレベル。 | |
--- | |
### インストール | |
```{r f19, eval=FALSE} | |
library(devtools) | |
install_github('slidify', 'ramnathv') | |
``` | |
以下も必要かも。 | |
```{r f26, eval=FALSE} | |
install_github('knitr', 'yihui') | |
install_github('whisker', 'edwindj') | |
install_github('markdown', 'rstudio') | |
``` | |
--- | |
### コード評価ももちろんオーケー | |
```{r f31, prompt = TRUE, comment = NA} | |
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) | |
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) | |
group <- gl(2,10,20, labels=c("Ctl","Trt")) | |
weight <- c(ctl, trt) | |
lm.D9 <- lm(weight ~ group) | |
coef(lm.D9) | |
``` | |
--- | |
### プロットもオーケー | |
```{r f32, warning=FALSE, fig.height=5} | |
par(family = "sans") | |
curve(sin(x), -10, 10, main = "正弦波") | |
``` | |
--- | |
### ggplot2もオーケー | |
```{r f33, warning=FALSE, fig.height=5} | |
library(ggplot2) | |
ggplot(NULL, aes(c(-10, 10))) + stat_function(fun=sin) | |
``` | |
--- | |
## これはいいね。おしまい。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r setup, echo = FALSE} | |
library(knitr) | |
library(grid) | |
opts_knit$set(out.format = 'html') | |
``` | |
--- | |
# Markdown, Knitr, and Slidify | |
state-of-the-art report/presentation generation in R | |
## @kohske | |
--- | |
### Easy, fun, and beautiful | |
```{r ch1, echo=TRUE, fig.align='right', fig.height=5, fig.width = 5, dev ='png', dev.args = list(bg="transparent")} | |
txt <- rep(c("E", "a", "s", "y"), 10) | |
grid.text(txt, 0.5+sin(2*pi*seq_along(txt)/length(txt))/2.2, 0.5+cos(2*pi*seq_along(txt)/length(txt))/2.2, gp = gpar(fontsize = 30, col = rainbow(length(txt)))) | |
``` | |
--- | |
### Reproducible | |
#### Freedom from | |
- Hand working | |
- Copy and paste | |
- Tweaking graphics by hand | |
#### All you need is | |
- Data | |
- Code | |
- Text | |
- Picture | |
--- | |
### Tools | |
All tools are available for free. | |
- [R][link_R]: environment for data analysis | |
- [knitr][link_knitr]: report generation tool for R | |
- [slidify][link_slidify]: HTML5 slide generator | |
[link_R]: http://www.r-project.org/ | |
[link_knitr]: http://yihui.name/knitr/ | |
[link_slidify]: http://ramnathv.github.com/slidify/ | |
- [Rstudio][link_rstudio]: excellent support for knitr. | |
[link_rstudio]: http://rstudio.org/ | |
![R logo](figure/r-logo.png) | |
--- | |
### Step-by-step tutorial | |
1. Prepare data | |
2. Write a code for data analysis | |
3. Write a code for summary output | |
4. Write a code for visualization | |
5. Knit them | |
6. Publish | |
--- | |
### 1. Prepare data | |
Ok, use `iris`. | |
```{r ch3} | |
head(iris) | |
``` | |
Of course, you may use data from your own experiment. | |
--- | |
### 2. Write a code for data analysis | |
summary of `iris` | |
```{r ch4} | |
summary(iris) | |
``` | |
--- | |
### 2. Write a code for data analysis | |
Old-fashioned statistical test. | |
```{r ch5} | |
library(reshape2) | |
library(plyr) | |
iris2 <- melt(iris) | |
dlply(iris2, .(variable), function(x) pairwise.t.test(x$value, x$Species)) | |
``` | |
--- | |
### 3. Write a code for summary output. | |
- For presentation, figures are better | |
- For report, [static html][link_static] version with detailed information may be better | |
[link_static]: http://kohske.github.com/sandbox/slidify/why-slidify/whyslidify_static.html | |
--- | |
### 4. Visualization | |
```{r ch6, fig.width=9, fig.height=5.5} | |
library(ggplot2) | |
ggplot(iris2, aes(variable, value, colour = Species)) + | |
geom_boxplot() + theme_grey(base_size=24) | |
``` | |
--- | |
### 5. Markdown | |
You can knit text, codes, and pictures in a [markdown][mdofficial] file. | |
[mdofficial]: http://daringfireball.net/projects/markdown/ | |
Here is the [markdown file][link_md] that [generates][link_generator] this slide. | |
[link_md]: http://kohske.github.com/sandbox/slidify/why-slidify/whyslidify.Rmd | |
[link_generator]: http://kohske.github.com/sandbox/slidify/why-slidify/generator.R | |
Then, all you need is: | |
- generate html | |
```{r ch7, eval = FALSE} | |
knit2html("whyslidify.Rmd") | |
``` | |
- generate HTML5 slide | |
```{r ch8, eval = FALSE} | |
slidify("whyslidify.Rmd") | |
``` | |
--- | |
### 6. Publish | |
- Upload the html and relevant files. | |
- Let your boss or your client know the url. | |
--- | |
### How to install | |
```{r ch9, eval = FALSE} | |
install.packages('devtools') | |
library(devtools) | |
install_github('slidify', 'ramnathv') | |
install_github('knitr', 'yihui') | |
install_github('whisker', 'edwindj') | |
install_github('markdown', 'rstudio') | |
``` | |
- [Rstudio][link_rstudio] supports knitr. | |
- It also provides a space for publication of knitted report, [Rpubs][link_rpubs]. | |
[link_rpubs]: http://www.rpubs.com/ | |
[link_rstudio]: http://rstudio.org/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great!!
Now I could upload the slide. Thanks.
http://rpubs.com/kohske/318