Skip to content

Commit 851a889

Browse files
committed
First commit
0 parents  commit 851a889

11 files changed

+177
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.pdf
2+
.Rproj.user
3+
.Rhistory
4+
_cache
5+
_site
6+
cache
7+
diamonds.csv
8+
temp.Rmd
9+
*.html
10+
*_cache
11+
*_files
12+
figures

.travis.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: c
2+
3+
before_install:
4+
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
5+
- chmod 755 ./travis-tool.sh
6+
- ./travis-tool.sh bootstrap
7+
8+
install:
9+
# Install binary pandoc from Rstudio
10+
- export PATH="$HOME/pandoc:$PATH"
11+
- mkdir $HOME/pandoc
12+
- curl -O https://s3.amazonaws.com/rstudio-buildtools/pandoc-1.12.3.zip
13+
- unzip -j pandoc-1.12.3.zip pandoc-1.12.3/linux/debian/x86_64/pandoc
14+
-d $HOME/pandoc
15+
- chmod +x $HOME/pandoc/pandoc
16+
- pandoc --version
17+
18+
# Install jekyll
19+
- travis_retry gem install jekyll mime-types
20+
21+
# Install R packages
22+
- ./travis-tool.sh r_binary_install knitr png
23+
- ./travis-tool.sh r_install ggplot2 dplyr tidyr
24+
- ./travis-tool.sh github_package hadley/bookdown
25+
26+
script: jekyll build
27+
28+
after_success:
29+
- cp -r figures/ _site/figures

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/us/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# R packages
2+
3+
This is code and text behind the [R for data science](http://r4ds.had.co.nz)
4+
book.
5+
6+
The site is built using jekyll, with a custom plugin to render `.rmd` files with
7+
knitr and pandoc. To create the site, you need:
8+
9+
* jekyll gem: `gem install jekyll`
10+
* bookdown: `install_github("hadley/bookdown")`
11+
* [pandoc](http://johnmacfarlane.net/pandoc/)
12+
* [knitr](http://yihui.name/knitr/): `install.packages("knitr")`

_config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: R packages
2+
markdown: redcarpet
3+
highlighter: pygments
4+
5+
exclude: ["CONTRIBUTING.md", "README.md", "book"]

_plugins/knit.r

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/Rscript
2+
library(rmarkdown)
3+
library(bookdown)
4+
library(methods)
5+
6+
args <- commandArgs(trailingOnly = TRUE)
7+
path <- args[1]
8+
9+
if (!file.exists(path)) {
10+
stop("Can't find path ", path, call. = FALSE)
11+
}
12+
13+
if (file.access(path, 4) != 0) {
14+
stop("Can't read path ", path, call. = FALSE)
15+
}
16+
17+
html_path <- render(path, html_chapter(raw = TRUE, toc = "toc.rds"),
18+
quiet = TRUE)
19+
20+
read_file <- function(path) {
21+
size <- file.info(path)$size
22+
readChar(path, size, useBytes = TRUE)
23+
}
24+
cat(read_file(html_path))

_plugins/rmarkdown.rb

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'tempfile'
2+
3+
module Jekyll
4+
class RMarkdownConverter < Converter
5+
safe :false
6+
priority :high
7+
8+
def matches(ext)
9+
ext =~ /^\.(rmd|rmarkdown)$/i
10+
end
11+
12+
def output_ext(ext)
13+
".html"
14+
end
15+
16+
def convert(content)
17+
f = File.new("temp.Rmd", "w")
18+
f.write(content)
19+
f.write("\n")
20+
f.flush
21+
22+
# http://rubyquicktips.com/post/5862861056/execute-shell-commands
23+
content = `_plugins/knit.r temp.Rmd`
24+
25+
if $?.exitstatus != 0
26+
raise "Knitting failed"
27+
end
28+
29+
content
30+
# File.unlink f.path
31+
end
32+
end
33+
end

contribute.rmd

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Contributing
3+
layout: default
4+
---
5+
6+
# Contributing
7+
8+
This book has been developed in the open, and it wouldn't be nearly as good
9+
without your contributions. There are a number of ways you can help make the
10+
book even better:
11+
12+
* If you don't understand something, please
13+
[let me know](mailto:[email protected]). Your feedback on what is confusing
14+
or hard to understand is valuable.
15+
16+
* If you spot a typo, feel free to edit the underlying page and send a pull
17+
request. If you've never done this before, the process is very easy:
18+
19+
* Click the edit this page on the sidebar.
20+
21+
* Make the changes using github's in-page editor and save.
22+
23+
* Submit a pull request and include a brief description of your changes.
24+
"Fixing typos" is perfectly adequate.
25+
26+
* If you make significant changes, include the phrase "I assign the
27+
copyright of this contribution to Hadley Wickham" - I need this so I can
28+
publish the printed book.

cover.png

269 KB
Loading

index.rmd

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout: default
3+
title: Welcome
4+
output: bookdown::html_chapter
5+
---
6+
7+
# R for Data Science
8+
9+
This is the book site for __"R for data science"__. It will be published with O'Reilly in July 2016.
10+
11+
<img src="cover.png" width="250" height="328" alt="Cover image" />
12+
13+
14+
<ul class="toc">
15+
{% include package-nav.html %}
16+
</ul>
17+

r4ds.Rproj

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: XeLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes

0 commit comments

Comments
 (0)