-
-
Save kohske/2855525 to your computer and use it in GitHub Desktop.
```{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) | |
``` | |
--- | |
## これはいいね。おしまい。 |
```{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/ | |
 | |
--- | |
### 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/ |
Excellent. I just realized that I had not pushed the latest version that I was talking to you about. If you reinstall it, you can get rid of the slidify logo as well, since I moved it to a custom css folder that I would use for my slide decks.
Thanks, updated.
I have one feature request. It would be better if I can manually set the title of the slide page (now "presentation").
If it is not set, the title of the first page may be used for the title of the slide.
Can you add this to the issues page so that I don't forget it?
I have implemented it so that you can set it manually by using
opts <- modifyList(slidifyOptions(), list(title = 'This is my Title'))
slidify("whyslidify.Rmd", options = opts)
I would still like it if you an add this request to the issues page, so that I remember implementing automatic title detection from the first slide.
@kohske. The latest version of slidify
makes uploading slides to rpubs
a breeze. If your presentation is named slides.Rmd
, just do the following:
opts <- slidifyOptions()
opts$embed = TRUE
slidify('slides.Rmd', options = opts)
rpubsUpload('My Presentation', 'slides.html')
Let me know if it works for you and if you have any suggestions. I could wrap this up in a helper function, but I thought people might want to view the presentation locally before uploading, so kept it separate.
Hi, thanks.
With the latest version, the slide cannot be correctly generated.
Perhaps the process of headers are broken.
Great!!
Now I could upload the slide. Thanks.
Yes, I did it. Thanks. Perhaps you see the cache of browser.
Please find the repo directly here: https://github.com/kohske/kohske.github.com/tree/master/sandbox/slidify/why-slidify