Skip to content

Instantly share code, notes, and snippets.

@timcameron
Created November 16, 2013 13:00
Show Gist options
  • Save timcameron/7499942 to your computer and use it in GitHub Desktop.
Save timcameron/7499942 to your computer and use it in GitHub Desktop.
My Second Presentation
<!DOCTYPE html>
<html>
<head>
<title>Aussie jerbs</title>
<meta charset="utf-8">
<meta name="description" content="Aussie jerbs">
<meta name="author" content="Tim Cameron">
<meta name="generator" content="slidify" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" href="libraries/frameworks/io2012/css/default.css" media="all" >
<link rel="stylesheet" href="libraries/frameworks/io2012/css/phone.css"
media="only screen and (max-device-width: 480px)" >
<link rel="stylesheet" href="libraries/frameworks/io2012/css/slidify.css" >
<link rel="stylesheet" href="libraries/highlighters/highlight.js/css/tomorrow.css" />
<base target="_blank"> <!-- This amazingness opens all links in a new tab. --> <link rel=stylesheet href="./assets/css/ribbons.css"></link>
<!-- Grab CDN jQuery, fall back to local if offline -->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"></script>
<script>window.jQuery || document.write('<script src="libraries/widgets/quiz/js/jquery.js"><\/script>')</script>
<script data-main="libraries/frameworks/io2012/js/slides"
src="libraries/frameworks/io2012/js/require-1.0.8.min.js">
</script>
</head>
<body style="opacity: 0">
<slides class="layout-widescreen">
<!-- LOGO SLIDE -->
<slide class="title-slide segue nobackground">
<hgroup class="auto-fadein">
<h1>Aussie jerbs</h1>
<h2>Playing around with R, Rmarkdown &amp; Slidify</h2>
<p>Tim Cameron<br/></p>
</hgroup>
<article></article>
</slide>
<!-- SLIDES -->
<slide class="" id="slide-1" style="background:;">
<hgroup>
<h2>Showing off what can be achieved without leaving RStudio</h2>
</hgroup>
<article data-timings="">
<p>This is not serious analysis of Australian employment data. I just had jobs data lying around in formats that were suited to show how <code>ggplot2</code>, <code>googleVis</code>, <code>Shiny</code> &amp; <code>rCharts</code> could all be implemented into a <code>Slidify</code> presentation.</p>
<div align="center">
<img src="http://24.media.tumblr.com/tumblr_lrq4pfRwh51r3uvuvo1_500.gif">
</div>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-2" style="background:;">
<hgroup>
<h2>Chart with ggplot. 1/2</h2>
</hgroup>
<article data-timings="">
<p>The code below is a &#39;chunk&#39; which is evaluated when I &#39;knit&#39; my <code>.Rmd</code> file.</p>
<pre><code class="r">library(ggplot2)
library(Quandl)
library(reshape2)
jobs &lt;- Quandl(&quot;AUSBS/6291008&quot;)[, 1:3]
names(jobs) &lt;- c(&quot;Date&quot;, &quot;M&quot;, &quot;F&quot;)
jobs &lt;- melt(jobs, id = &quot;Date&quot;)
</code></pre>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-3" style="background:;">
<hgroup>
<h2>Chart with ggplot. 2/2</h2>
</hgroup>
<article data-timings="">
<p>Note, I only insert code here. The chart is generated as a result.</p>
<p><p align = "center"></p>
<pre><code class="r">ggplot(jobs) + geom_line(aes(Date, value, colour = variable)) + labs(title = &quot;Jobs by gender&quot;)
</code></pre>
<p><img src="assets/fig/ggplot%20charts%202.png" alt="plot of chunk ggplot charts 2"> </p>
<p><p></p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-4" style="background:;">
<hgroup>
<h2>How about a map? 1/2</h2>
</hgroup>
<article data-timings="">
<p>Here&#39;s some code</p>
<pre><code class="r">suppressPackageStartupMessages(library(googleVis))
GeoChart &lt;- gvisGeoChart(Exports, &quot;Country&quot;, &quot;Profit&quot;, options = list(region = &quot;AU&quot;))
# I supressed table creation from ouput
data &lt;- read.csv(&quot;C:/Users/Tim Cameron/Documents/Projects/Slides/unemployment.csv&quot;)
GeoChart &lt;- gvisGeoChart(data, &quot;State&quot;, &quot;Unemployment&quot;, options = list(region = &quot;AU&quot;,
resolution = &quot;provinces&quot;, colorAxis = &quot;{values:[4,8],colors:[\&#39;green&#39;,\&#39;grey&#39;]}&quot;))
</code></pre>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-5" style="background:;">
<hgroup>
<h2>How about a map? 2/2</h2>
</hgroup>
<article data-timings="">
<p>And here&#39;s a map</p>
<pre><code class="r">print(GeoChart, &quot;chart&quot;)
</code></pre>
<!-- GeoChart generated in R 3.0.2 by googleVis 0.4.3 package -->
<!-- Sat Nov 16 23:40:47 2013 -->
<!-- jsHeader -->
<script type="text/javascript">
// jsData
function gvisDataGeoChartID2be03c792422 () {
var data = new google.visualization.DataTable();
var datajson =
[
[
"AU-NSW",
5.8
],
[
"AU-QLD",
5.8
],
[
"AU-NT",
5.8
],
[
"AU-SA",
6.6
],
[
"AU-TAS",
8.2
],
[
"AU-VIC",
4.5
],
[
"AU-WA",
4.3
],
[
"AU-ACT",
4.4
]
];
data.addColumn('string','State');
data.addColumn('number','Unemployment');
data.addRows(datajson);
return(data);
}
// jsDrawChart
function drawChartGeoChartID2be03c792422() {
var data = gvisDataGeoChartID2be03c792422();
var options = {};
options["width"] = 556;
options["height"] = 347;
options["region"] = "AU";
options["resolution"] = "provinces";
options["colorAxis"] = {values:[4,8],colors:['green','grey']};
var chart = new google.visualization.GeoChart(
document.getElementById('GeoChartID2be03c792422')
);
chart.draw(data,options);
}
// jsDisplayChart
(function() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
var chartid = "geochart";
// Manually see if chartid is in pkgs (not all browsers support Array.indexOf)
var i, newPackage = true;
for (i = 0; newPackage && i < pkgs.length; i++) {
if (pkgs[i] === chartid)
newPackage = false;
}
if (newPackage)
pkgs.push(chartid);
// Add the drawChart function to the global list of callbacks
callbacks.push(drawChartGeoChartID2be03c792422);
})();
function displayChartGeoChartID2be03c792422() {
var pkgs = window.__gvisPackages = window.__gvisPackages || [];
var callbacks = window.__gvisCallbacks = window.__gvisCallbacks || [];
window.clearTimeout(window.__gvisLoad);
// The timeout is set to 100 because otherwise the container div we are
// targeting might not be part of the document yet
window.__gvisLoad = setTimeout(function() {
var pkgCount = pkgs.length;
google.load("visualization", "1", { packages:pkgs, callback: function() {
if (pkgCount != pkgs.length) {
// Race condition where another setTimeout call snuck in after us; if
// that call added a package, we must not shift its callback
return;
}
while (callbacks.length > 0)
callbacks.shift()();
} });
}, 100);
}
// jsFooter
</script>
<!-- jsChart -->
<script type="text/javascript" src="https://www.google.com/jsapi?callback=displayChartGeoChartID2be03c792422"></script>
<!-- divChart -->
<div id="GeoChartID2be03c792422"
style="width: 556px; height: 347px;">
</div>
<p>Note that this chunk requires the setting <code>results=&#39;asis&#39;</code> to render.</p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-6" style="background:;">
<hgroup>
<h2>Shiny and rCharts</h2>
</hgroup>
<article data-timings="">
<ul>
<li><p>The following two slides show a Shiny app and an rCharts chart that I created previously and have embedded with iframes. </p></li>
<li><p>The problem is, if you interact with the apps, the arrow buttons can&#39;t be used to navigate until you refresh (F5) the webpage. So please refresh to restore functionality. </p></li>
</ul>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-7" style="background:;">
<hgroup>
<h2>A Shiny app</h2>
</hgroup>
<article data-timings="">
<div align="center">
<iframe
src="http://spark.rstudio.com/tim/AusEmploymentFlows/" >
</iframe></div>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-8" style="background:;">
<hgroup>
<h2>Can put <code>rCharts</code> in there too</h2>
</hgroup>
<article data-timings="">
<div align="center">
<iframe
src="http://bl.ocks.org/timcameron/raw/7498872/" >
</iframe></div>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="" id="slide-9" style="background:;">
<hgroup>
<h2>Some resources that helped me make these slides</h2>
</hgroup>
<article data-timings="">
<ul>
<li><a href="http://www.rstudio.com/ide/docs/r_markdown">R Markdown overview</a></li>
<li><a href="http://rpubs.com/gallery/options">Customizing Chunk Options</a></li>
<li>The package <a href="http://slidify.org/">Slidify</a></li>
</ul>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="backdrop"></slide>
</slides>
<div class="pagination pagination-small" id='io2012-ptoc' style="display:none;">
<ul>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=1 title='Showing off what can be achieved without leaving RStudio'>
1
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=2 title='Chart with ggplot. 1/2'>
2
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=3 title='Chart with ggplot. 2/2'>
3
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=4 title='How about a map? 1/2'>
4
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=5 title='How about a map? 2/2'>
5
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=6 title='Shiny and rCharts'>
6
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=7 title='A Shiny app'>
7
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=8 title='Can put <code>rCharts</code> in there too'>
8
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=9 title='Some resources that helped me make these slides'>
9
</a>
</li>
</ul>
</div> <!--[if IE]>
<script
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js">
</script>
<script>CFInstall.check({mode: 'overlay'});</script>
<![endif]-->
</body>
<!-- Load Javascripts for Widgets -->
<!-- LOAD HIGHLIGHTER JS FILES -->
<script src="libraries/highlighters/highlight.js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- DONE LOADING HIGHLIGHTER JS FILES -->
</html>
---
title : Aussie jerbs
subtitle : Playing around with R, Rmarkdown & Slidify
author : Tim Cameron
job :
framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : tomorrow #
widgets : [] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
---
## Showing off what can be achieved without leaving RStudio
This is not serious analysis of Australian employment data. I just had jobs data lying around in formats that were suited to show how `ggplot2`, `googleVis`, `Shiny` & `rCharts` could all be implemented into a `Slidify` presentation.
<div align="center">
<img src="http://24.media.tumblr.com/tumblr_lrq4pfRwh51r3uvuvo1_500.gif">
</div>
---
## Chart with ggplot. 1/2
The code below is a 'chunk' which is evaluated when I 'knit' my `.Rmd` file.
```{r ggplot1, warning=FALSE}
library(ggplot2)
library(Quandl)
library(reshape2)
jobs <- Quandl("AUSBS/6291008")[,1:3]
names(jobs) <- c("Date","M","F")
jobs <- melt(jobs,id="Date")
```
---
## Chart with ggplot. 2/2
Note, I only insert code here. The chart is generated as a result.
<p align = "center">
``` {r ggplot charts 2, fig.align='center', fig.height=5}
ggplot(jobs) + geom_line(aes(Date,value,colour=variable)) +
labs(title="Jobs by gender")
```
<p>
---
## How about a map? 1/2
Here's some code
``` {r chart1}
suppressPackageStartupMessages(library(googleVis))
GeoChart <- gvisGeoChart(Exports, "Country", "Profit",
options=list(region="AU"))
#I supressed table creation from ouput
data <- read.csv("C:/Users/Tim Cameron/Documents/Projects/Slides/unemployment.csv")
GeoChart <- gvisGeoChart(data, "State", "Unemployment",
options=list(region="AU",
resolution='provinces',
colorAxis="{values:[4,8],colors:[\'green',\'grey']}"))
```
---
## How about a map? 2/2
And here's a map
``` {r chart2, results='asis', fig.align='center'}
print(GeoChart, "chart")
```
Note that this chunk requires the setting `results='asis'` to render.
---
## Shiny and rCharts
+ The following two slides show a Shiny app and an rCharts chart that I created previously and have embedded with iframes.
+ The problem is, if you interact with the apps, the arrow buttons can't be used to navigate until you refresh (F5) the webpage. So please refresh to restore functionality.
---
## A Shiny app
<div align="center">
<iframe
src="http://spark.rstudio.com/tim/AusEmploymentFlows/" >
</iframe></div>
---
## Can put `rCharts` in there too
<div align="center">
<iframe
src="http://bl.ocks.org/timcameron/raw/7498872/" >
</iframe></div>
---
## Some resources that helped me make these slides
+ [R Markdown overview](http://www.rstudio.com/ide/docs/r_markdown)
+ [Customizing Chunk Options](http://rpubs.com/gallery/options)
+ The package [Slidify](http://slidify.org/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment