Skip to content

Instantly share code, notes, and snippets.

@jtrecenti
Created August 26, 2014 22:38
Show Gist options
  • Select an option

  • Save jtrecenti/1bd612d9e0a1fd9daf36 to your computer and use it in GitHub Desktop.

Select an option

Save jtrecenti/1bd612d9e0a1fd9daf36 to your computer and use it in GitHub Desktop.
exemplo de dplyr e ggplot2
require(dplyr)
require(ggplot2)
require(lubridate)
require(scales)
a <- c('2012-01-01')
a2 <- ymd(a)+days(1:1000)
a3 <- as.Date(a2)
d <- data.frame(X=rnorm(1000),
Y=c(rnorm(1000)[-1], 8),
Z=rep(LETTERS[1:3], c(200,300,500)),
data=a2)
d %>%
mutate(id=1:n()) %>%
filter(Y < quantile(Y, 0.25),
X > quantile(Y, 0.75)) %>%
ggplot(aes(x=as.Date(data), y=Y)) +
geom_point() +
geom_line() +
scale_x_date(breaks=date_breaks('3 weeks')) +
theme_bw() +
theme(axis.text.x=element_text(angle=45, hjust=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment