Last active
August 29, 2015 14:03
-
-
Save jcheng5/e28025240c41b2fb2c80 to your computer and use it in GitHub Desktop.
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(dplyr, warn.conflicts=FALSE) | |
library(ggplot2) | |
daily <- readRDS("daily.rds") | |
daily | |
# Take the data from 2014 | |
perioddata <- daily %>% filter(date >= as.Date("2014-01-01")) | |
perioddata | |
# Take a look only at packages we're interested in | |
pkgdata <- perioddata %>% filter(package %in% c("BRugs", "rbugs", "R2WinBUGS")) | |
pkgdata | |
# Plot | |
ggplot(pkgdata, aes(x = date, y = count, color = package)) + | |
expand_limits(y = 0) + | |
geom_line() | |
# Seems a little rough. Let's smooth it out | |
ggplot(pkgdata, aes(x = date, y = count, color = package)) + | |
expand_limits(y = 0) + | |
geom_smooth(se = FALSE, method = "loess") | |
# Maybe too smooth... try less | |
ggplot(pkgdata, aes(x = date, y = count, color = package)) + | |
expand_limits(y = 0) + | |
geom_smooth(se = FALSE, method = "loess", span = 0.4) |
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: "Download counts" | |
author: "Joe Cheng <joe@rstudio.com>" | |
output: html_document | |
--- | |
Source: http://cran-logs.rstudio.com/ | |
```{r echo=FALSE} | |
library(dplyr, warn.conflicts=FALSE) | |
library(ggplot2) | |
daily <- readRDS("daily.rds") | |
``` | |
```{r results='hold'} | |
# Take the data from 2014 | |
perioddata <- daily %>% filter(date >= as.Date("2014-01-01")) | |
# Take a look only at packages we're interested in | |
pkgdata <- perioddata %>% filter(package %in% c("BRugs", "rbugs", "R2WinBUGS")) | |
# Plot with some smoothing | |
ggplot(pkgdata, aes(x = date, y = count, color = package)) + | |
expand_limits(y = 0) + | |
geom_smooth(se = FALSE, method = "loess", span = 0.4) | |
``` |
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: "Download counts" | |
author: "Joe Cheng <joe@rstudio.com>" | |
output: html_document | |
runtime: shiny | |
--- | |
Source: http://cran-logs.rstudio.com/ | |
```{r echo=FALSE} | |
library(dplyr, warn.conflicts=FALSE) | |
library(ggplot2) | |
daily <- readRDS("daily.rds") | |
``` | |
```{r echo=FALSE, results='hold'} | |
dateRangeInput("daterange", "Period", | |
"2014-01-01", max(daily$date), min(daily$date), max(daily$date)) | |
perioddata <- reactive({ | |
daily %>% filter(date >= input$daterange[1] & date <= input$daterange[2]) | |
}) | |
selectInput("package", "Package(s)", multiple = TRUE, | |
choices = sort(unique(daily$package)), selected = c("BRugs", "rbugs", "R2WinBUGS")) | |
pkgdata <- reactive({ | |
perioddata() %>% filter(package %in% input$package) | |
}) | |
sliderInput("smoothness", "Smoothness", 0, 1, 0.3) | |
# Plot with a bit of smoothing | |
renderPlot({ | |
ggplot(pkgdata(), aes(x = date, y = count, color = package)) + | |
expand_limits(y = 0) + | |
geom_smooth(se = FALSE, method = "loess", span = input$smoothness) | |
}) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment