Owen C. Thompson
2019-02-27
This is a great idea for creating reproducible presentations. I see enormous potential for these projects in the future. This is simple a sample where I can practice, experiment, and document pain-points in my learning process.
That said, let’s get to it!
I definitely spent wayyyy too much time trying to add the above GIF. But I found Hao Zhu's giphyr add-in to be the most helpful!
Let's demonstrate the benefits of creating adding code directly within a presentation. First, let's create dummy time-series data of a random variable Y, observed from 1901 to 2000.
set.seed(2019)
needs(tidyverse)
data <- data.frame(X = seq(1901, 2000),
y0 = 1:100,
y1 = abs(rnorm(sd = 8, n = 100))) %>%
rowwise() %>%
mutate(y2 = sin(y0),
Y = sum(y0, y1, y2))
head(data)
Source: local data frame [6 x 5]
Groups: <by row>
# A tibble: 6 x 5
X y0 y1 y2 Y
<int> <int> <dbl> <dbl> <dbl>
1 1901 1 5.91 0.841 7.75
2 1902 2 4.12 0.909 7.03
3 1903 3 13.1 0.141 16.3
4 1904 4 7.33 -0.757 10.6
5 1905 5 10.1 -0.959 14.2
6 1906 6 5.91 -0.279 11.6
I love how easy it is to incorporate plots within a presentation. As with R Markdown, I can hide the source code and only present relevant information in a neat format.
Let's fit a linear regression on our data, defining the relationship between X and Y.
model <- lm(Y~X, data)
summary(model)
Call:
lm(formula = Y ~ X, data = data)
Residuals:
Min 1Q Median 3Q Max
-6.4135 -3.1194 -0.6813 1.6359 13.8722
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.816e+03 2.881e+01 -63.03 <2e-16 ***
X 9.598e-01 1.477e-02 64.99 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.263 on 98 degrees of freedom
Multiple R-squared: 0.9773, Adjusted R-squared: 0.9771
F-statistic: 4223 on 1 and 98 DF, p-value: < 2.2e-16
It doesn't make much sense to evaluate the quality of our model as this is a very rudimentary example, but we can still explore how R Presentations allow us to cleanly report on our analyses.
I explored very basic elements of R Presentations. In the last year I've learned how to maneuver markdown, learning some HTML along the way. I see potential for incorporating other languages like Python, CSS, and D3.js into future presentations and look forward to using more complex data objects.
This is a very rudimentary example of how R Presentations can be used to make presentating fun and easy. Powerpoint is great but as someone who spends so much time in RStudio I see so many benefits of working within the same IDE where I conduct my analyses. I would like to see how easy it is to download and share R Presentations outside of RStudio - I'd like to explore the formats available for download ways that I can share presentations with others.
There are various presentation templates and customizations I've yet to explore, and I've only scratched the surface!