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
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown) | |
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96. | |
This combination of tools provides an exciting improvement in usability for | |
[reproducible analysis](http://stats.stackexchange.com/a/15006/183). | |
Specifically, this post | |
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96; | |
(2) provides a basic example of producing console output and plots using R Markdown; | |
(3) highlights several code chunk options such as caching and controlling how input and output is displayed; | |
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and | |
(5) discusses the implications of R Markdown. |
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
............................................________ | |
....................................,.-'"...................``~., | |
.............................,.-"..................................."-., | |
.........................,/...............................................":, | |
.....................,?......................................................, | |
.................../...........................................................,} | |
................./......................................................,:`^`..} | |
.............../...................................................,:"........./ | |
..............?.....__.........................................:`.........../ | |
............./__.(....."~-,_..............................,:`........../ |
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
1,2012-01-02,New Year Day | |
2,2012-01-16,Martin Luther King Jr. Day | |
3,2012-02-20,Presidents Day (Washingtons Birthday) | |
4,2012-05-28,Memorial Day | |
5,2012-07-04,Independence Day | |
6,2012-09-03,Labor Day | |
7,2012-10-08,Columbus Day | |
8,2012-11-12,Veterans Day | |
9,2012-11-22,Thanksgiving Day | |
10,2012-12-25,Christmas Day |
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
--- | |
title: "twee demo" | |
author: "Jenny Bryan" | |
date: "17 August, 2014" | |
output: | |
html_document: | |
toc: TRUE | |
keep_md: TRUE | |
--- |
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
#=================================================== | |
# Demo multi-function roxygen2 - three ways to do it | |
#=================================================== | |
# This shows how things do work, including wierd corner cases, not | |
# how they should be done. Most of the information comes from | |
# http://r-pkgs.had.co.nz/man.html | |
#==================================================== | |
# Demo multi-function roxygen2 page using @describeIn |
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
CREATE OR REPLACE VIEW sabermetrics_batting AS | |
SELECT | |
batting.*, | |
-- PA - Plate Appearances | |
(batting.AB + batting.BB + batting.HBP + batting.SF + batting.SH) as PA, | |
-- BB% - Walk Percentage (http://www.fangraphs.com/library/offense/rate-stats/) | |
round((batting.BB / (batting.AB + batting.BB + batting.HBP + batting.SF + batting.SH)), 3) as BBpct, |
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
x <- c("Brown bear", "Red bird", "Yellow duck", "Blue horse", "Green frog", "Purple Cat", "Goldfish", "Teacher") | |
txt <- capture.output(cat( | |
sprintf("%s, %s, what do you see?\n I see a %s looking at me.\n", head(x, -1), head(x, -1), tail(x, -1)), | |
sprintf("Teacher, Teacher what do you see\n I see Children looking at me.\nChildren Children what do you see?\n We see a %s and a Teacher looking at us, that's what we see.", | |
paste0(collapse = ", ", head(x, -1))), sep = "")) | |
txt | |
#> Brown bear, Brown bear, what do you see? | |
#> I see a Red bird looking at me. | |
#> Red bird, Red bird, what do you see? | |
#> I see a Yellow duck looking at me. |
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
library(broom) | |
library(ggplot2) | |
# read in the data | |
# others available here: http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/stat_res_plots.html | |
owl <- read.table("http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/orly_owl_files/orly_owl_Lin_4p_5_flat.txt", | |
header = FALSE) | |
# fit the linear model | |
fit <- lm(V1 ~ . - 1, data = owl) |
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
--- | |
title: "Transform Data" | |
subtitle: "hands-on examples, with answers" | |
output: html_notebook | |
--- | |
<!-- This file by Charlotte Wickham (with some modifications by Martin Monkman) is licensed under a Creative Commons Attribution 4.0 International License, adapted from the orignal work at https://github.com/rstudio/master-the-tidyverse by RStudio and https://github.com/cwickham/data-science-in-tidyverse-solutions. --> | |
```{r setup} | |
library(tidyverse) |
OlderNewer