Skip to content

Commit

Permalink
Movies data moved to ggplot2 movies.
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jul 21, 2015
1 parent b889380 commit cfe24e2
Show file tree
Hide file tree
Showing 41 changed files with 85 additions and 58,927 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,7 @@ warnings_are_errors: true

r_github_packages:
- hadley/staticdocs
- hadley/ggplot2movies
- jimhester/covr

before_script:
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Expand Up @@ -24,6 +24,7 @@ Imports:
scales (>= 0.2.3),
stats
Suggests:
ggplot2movies,
hexbin,
Hmisc,
knitr,
Expand Down
5 changes: 5 additions & 0 deletions NEWS
@@ -1,6 +1,11 @@
ggplot2 1.0.1.9xxx
----------------------------------------------------------------

* The movies dataset has been moved into its own package, ggplot2movies,
because it was large and not terribly useful. If you've used the movies
dataset, you'll now need to explicitly load the package with
`library(ggplot2movies)`.

* The default legend will now allocate multiple rows (if vertical) or
columns (if horizontal) in order to make a legend that is more likely to
fit on the screen. You can override with the `nrow`/`ncol` arguments
Expand Down
6 changes: 3 additions & 3 deletions R/aes-colour-fill-alpha.r
Expand Up @@ -25,9 +25,9 @@
#' k + geom_bar()
#'
#' # Fill aesthetic can also be used with a continuous variable
#' m <- ggplot(movies, aes(x = rating))
#' m + geom_histogram()
#' m + geom_histogram(aes(fill = ..count..))
#' m <- ggplot(faithfuld, aes(waiting, eruptions))
#' m + geom_raster()
#' m + geom_raster(aes(fill = density))
#'
#' # Some geoms don't use both aesthetics (i.e. geom_point or geom_line)
#' b <- ggplot(economics, aes(x = date, y = unemploy))
Expand Down
2 changes: 2 additions & 0 deletions R/coord-polar.r
Expand Up @@ -41,6 +41,7 @@
#' labs(title = "Pac man")
#'
#' # Windrose + doughnut plot
#' if (require("ggplot2movies")) {
#' movies$rrating <- cut_interval(movies$rating, length = 1)
#' movies$budgetq <- cut_number(movies$budget, 4)
#'
Expand All @@ -51,6 +52,7 @@
#' # Race track plot
#' doh + geom_bar(width = 0.9, position = "fill") + coord_polar(theta = "y")
#' }
#' }
coord_polar <- function(theta = "x", start = 0, direction = 1) {
theta <- match.arg(theta, c("x", "y"))
r <- if (theta == "x") "y" else "x"
Expand Down
2 changes: 1 addition & 1 deletion R/geom-bar-histogram.r
Expand Up @@ -14,7 +14,7 @@
#' @export
#' @inheritParams geom_point
#' @examples
#' \donttest{
#' if (require("ggplot2movies")) {
#' set.seed(5689)
#' movies <- movies[sample(nrow(movies), 1000), ]
#' # Basic example
Expand Down
2 changes: 1 addition & 1 deletion R/geom-blank.r
Expand Up @@ -6,7 +6,7 @@
#' @export
#' @inheritParams geom_point
#' @examples
#' ggplot(movies, aes(length, rating)) + geom_blank()
#' ggplot(mtcars, aes(wt, mpg)) + geom_blank()
#' # Nothing to see here!
#'
#' # Take the following scatter plot
Expand Down
3 changes: 2 additions & 1 deletion R/geom-boxplot.r
Expand Up @@ -71,6 +71,7 @@
#' # Scale transformations occur before the boxplot statistics are computed.
#' # Coordinate transformations occur afterwards. Observe the effect on the
#' # number of outliers.
#' if (require("ggplot2movies")) {
#' library(plyr) # to access round_any
#' m <- ggplot(movies, aes(y = votes, x = rating,
#' group = round_any(rating, 0.5)))
Expand All @@ -86,6 +87,7 @@
#'
#' ggplot(movies, aes(year, budget)) +
#' geom_boxplot(aes(group=round_any(year, 10, floor)))
#' }
#'
#' # Using precomputed statistics
#' # generate sample data
Expand All @@ -100,7 +102,6 @@
#' p + geom_boxplot(varwidth = TRUE)
#'
#' # Update the defaults for the outliers by changing the defaults for geom_point
#'
#' p <- ggplot(mtcars, aes(factor(cyl), mpg))
#' p + geom_boxplot()
#'
Expand Down
2 changes: 2 additions & 0 deletions R/geom-path-.r
Expand Up @@ -15,6 +15,7 @@
#' @examples
#' \donttest{
#' # Generate data
#' if (require("ggplot2movies")) {
#' library(plyr)
#' myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
#' p <- ggplot(myear, aes(length, rating))
Expand All @@ -29,6 +30,7 @@
#'
#' # Set aesthetics to fixed value
#' p + geom_path(colour = "green")
#' }
#'
#' # Control line join parameters
#' df <- data.frame(x = 1:3, y = c(4, 1, 9))
Expand Down
2 changes: 2 additions & 0 deletions R/geom-path-line.r
Expand Up @@ -10,6 +10,7 @@
#' @export
#' @examples
#' # Summarise number of movie ratings by year of movie
#' if (require("ggplot2movies")) {
#' mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
#' nums <- tapply(df$length, df$year, length)
#' data.frame(rating=round(df$rating[1]), year = as.numeric(names(nums)), number=as.vector(nums))
Expand All @@ -28,6 +29,7 @@
#'
#' # Set aesthetics to fixed value
#' p + geom_line(colour = "red", size = 1)
#' }
#'
#' # Using a time series
#' ggplot(economics, aes(date, pop)) + geom_line()
Expand Down
8 changes: 0 additions & 8 deletions R/geom-ribbon-.r
Expand Up @@ -29,14 +29,6 @@
#' huron[huron$year > 1900 & huron$year < 1910, "level"] <- NA
#' h <- ggplot(huron, aes(x=year))
#' h + geom_ribbon(aes(ymin=level-1, ymax=level+1)) + geom_line(aes(y=level))
#'
#' # Another data set, with multiple y's for each x
#' m <- ggplot(movies, aes(y=votes, x=year))
#' (m <- m + geom_point())
#'
#' # The default summary isn't that useful
#' m + stat_summary(geom="ribbon", fun.ymin="min", fun.ymax="max")
#' m + stat_summary(geom="ribbon", fun.data="median_hilow")
#' }
geom_ribbon <- function (mapping = NULL, data = NULL, stat = "identity",
position = "identity", na.rm = FALSE, show_guide = NA, inherit.aes = TRUE, ...)
Expand Down
2 changes: 2 additions & 0 deletions R/geom-violin.r
Expand Up @@ -42,6 +42,7 @@
#' p + geom_violin(fill = "grey80", colour = "#3366FF")
#'
#' # Scales vs. coordinate transforms -------
#' if (require("ggplot2movies")) {
#' # Scale transformations occur before the density statistics are computed.
#' # Coordinate transformations occur afterwards. Observe the effect on the
#' # number of outliers.
Expand All @@ -59,6 +60,7 @@
#' ggplot(movies, aes(year, budget)) +
#' geom_violin(aes(group = round_any(year, 10, floor)))
#' }
#' }
geom_violin <- function (mapping = NULL, data = NULL, stat = "ydensity",
position = "dodge", trim = TRUE, scale = "area", show_guide = NA,
inherit.aes = TRUE, ...)
Expand Down
30 changes: 0 additions & 30 deletions R/ggplot2.r
Expand Up @@ -88,36 +88,6 @@ NULL
"midwest"


#' Movie information and user ratings from IMDB.com.
#'
#' The internet movie database, \url{http://imdb.com/}, is a website devoted
#' to collecting movie data supplied by studios and fans. It claims to be the
#' biggest movie database on the web and is run by amazon. More about
#' information imdb.com can be found online,
#' \url{http://imdb.com/help/show_leaf?about}, including information about
#' the data collection process,
#' \url{http://imdb.com/help/show_leaf?infosource}.
#'
#' Movies were selected for inclusion if they had a known length and had been
#' rated by at least one imdb user.
#'
#' @format A data frame with 28819 rows and 24 variables
#' \itemize{
#' \item title. Title of the movie.
#' \item year. Year of release.
#' \item budget. Total budget (if known) in US dollars
#' \item length. Length in minutes.
#' \item rating. Average IMDB user rating.
#' \item votes. Number of IMDB users who rated this movie.
#' \item r1-10. Multiplying by ten gives percentile (to nearest 10\%) of
#' users who rated this movie a 1.
#' \item mpaa. MPAA rating.
#' \item action, animation, comedy, drama, documentary, romance, short.
#' Binary variables representing if movie was classified as belonging to that genre.
#' }
#' @references \url{http://had.co.nz/data/movies/}
"movies"

#' Fuel economy data from 1999 and 2008 for 38 popular models of car
#'
#' This dataset contains a subset of the fuel economy data that the EPA makes
Expand Down
14 changes: 7 additions & 7 deletions R/save.r
Expand Up @@ -25,16 +25,16 @@
#' @export
#' @examples
#' \dontrun{
#' ggplot(movies, aes(rating)) + geom_histogram(binwidth = 0.1)
#' ggplot(mtcars, aes(mpg, wt)) + geom_point()
#'
#' ggsave("ratings.pdf")
#' ggsave("ratings.png")
#' ggsave("mtcars.pdf")
#' ggsave("mtcars.png")
#'
#' ggsave("ratings.pdf", width = 4, height = 4)
#' ggsave("ratings.pdf", width = 20, height = 20, units = "cm")
#' ggsave("mtcars.pdf", width = 4, height = 4)
#' ggsave("mtcars.pdf", width = 20, height = 20, units = "cm")
#'
#' unlink("ratings.pdf")
#' unlink("ratings.png")
#' unlink("mtcars.pdf")
#' unlink("mtcars.png")
#'
#' # specify device when saving to a file with unknown extension
#' # (for example a server supplied temporary file)
Expand Down
2 changes: 2 additions & 0 deletions R/scale-continuous.r
Expand Up @@ -11,6 +11,7 @@
#' @export
#' @examples
#' \donttest{
#' if (require(ggplot2movies)) {
#' m <- ggplot(subset(movies, votes > 1000), aes(rating, votes)) +
#' geom_point(na.rm = TRUE)
#' m
Expand Down Expand Up @@ -72,6 +73,7 @@
#' scale_x_log10() +
#' scale_y_log10()
#' }
#' }
scale_x_continuous <- function(name = NULL, breaks = waiver(),
minor_breaks = waiver(), labels = waiver(),
limits = NULL, expand = waiver(), oob = censor,
Expand Down
17 changes: 7 additions & 10 deletions R/stat-bin.r
Expand Up @@ -29,19 +29,16 @@
#' # If right = TRUE, and intervals are of the form (a, b]
#' base + stat_bin(binwidth = 1, drop = FALSE, right = TRUE, col = "black")
#'
#' m <- ggplot(movies, aes(x=rating))
#' m + stat_bin()
#' m + stat_bin(binwidth=0.1)
#' m + stat_bin(breaks=seq(4,6, by=0.1))
#' d <- ggplot(diamonds, aes(carat))
#' d + stat_bin()
#' d + stat_bin(binwidth = 0.1)
#' d + stat_bin(breaks=seq(0, 2, by = 0.01))
#' # See geom_histogram for more histogram examples
#'
#' # To create a unit area histogram, use aes(y = ..density..)
#' (linehist <- m + stat_bin(aes(y = ..density..), binwidth=0.1,
#' geom="line", position="identity"))
#' linehist + stat_density(colour="blue", fill=NA)
#'
#' # Also works with categorical variables
#' ggplot(movies, aes(x=mpaa)) + stat_bin()
#' linehist <- d + geom_freqpoly(aes(y = ..density..), binwidth = 0.1)
#' linehist
#' linehist + stat_density(colour = "blue", fill = NA)
#' }
stat_bin <- function (mapping = NULL, data = NULL, geom = "bar",
position = "stack", width = 0.9, drop = FALSE, right = FALSE,
Expand Down
2 changes: 2 additions & 0 deletions R/stat-density.r
Expand Up @@ -24,6 +24,7 @@
#' @export
#' @examples
#' \donttest{
#' if (require("ggplot2movies")) {
#' m <- ggplot(movies, aes(x = rating))
#' m + geom_density()
#'
Expand Down Expand Up @@ -88,6 +89,7 @@
#' m + geom_density(fill=NA)
#' m + geom_density(fill=NA) + aes(y = ..count..)
#' }
#' }
stat_density <- function (mapping = NULL, data = NULL, geom = "area",
position = "stack", adjust = 1, kernel = "gaussian", trim = FALSE,
na.rm = FALSE, show_guide = NA, inherit.aes = TRUE, ...)
Expand Down
2 changes: 2 additions & 0 deletions R/stat-quantile.r
Expand Up @@ -15,6 +15,7 @@
#' @export
#' @examples
#' \donttest{
#' if (require("ggplot2movies")) {
#' msamp <- movies[sample(nrow(movies), 1000), ]
#' m <- ggplot(msamp, aes(year, rating)) + geom_point()
#' m + stat_quantile()
Expand All @@ -40,6 +41,7 @@
#' # Set aesthetics to fixed value
#' m + stat_quantile(colour = "red", size = 2, linetype = 2)
#' }
#' }
stat_quantile <- function (mapping = NULL, data = NULL, geom = "quantile",
position = "identity", quantiles = c(0.25, 0.5, 0.75), formula = NULL,
method = "rq", na.rm = FALSE, show_guide = NA, inherit.aes = TRUE, ...)
Expand Down
2 changes: 2 additions & 0 deletions R/stat-summary.r
Expand Up @@ -91,6 +91,7 @@
#' xlab("cyl")
#' m
#' # An example with highly skewed distributions:
#' if (require("ggplot2movies")) {
#' set.seed(596)
#' mov <- movies[sample(nrow(movies), 1000), ]
#' m2 <- ggplot(mov, aes(x= factor(round(rating)), y=votes)) + geom_point()
Expand All @@ -111,6 +112,7 @@
#' # standard errors.
#' m2 + coord_trans(y="log10")
#' }
#' }
stat_summary <- function (mapping = NULL, data = NULL, geom = "pointrange",
position = "identity", show_guide = NA, inherit.aes = TRUE, ...)
{
Expand Down
2 changes: 2 additions & 0 deletions R/translate-qplot-lattice.r
Expand Up @@ -9,6 +9,7 @@
#' \dontrun{
#' library(lattice)
#'
#' if (require("ggplot2movies")) {
#' xyplot(rating ~ year, data=movies)
#' qplot(year, rating, data=movies)
#'
Expand All @@ -35,6 +36,7 @@
#'
#' xyplot(wt ~ mpg, mtcars, type = c("p","r"))
#' qplot(mpg, wt, data = mtcars, geom = c("point","smooth"), method = "lm")
#' }
#'
#' # The capabilities for scale manipulations are similar in both ggplot2 and
#' # lattice, although the syntax is a little different.
Expand Down
4 changes: 0 additions & 4 deletions data-raw/movies.R

This file was deleted.

0 comments on commit cfe24e2

Please sign in to comment.