##import data

data <- read_excel("../00_data/myData.xlsx")
data
## # A tibble: 32,754 × 20
##         id original_title original_language overview tagline release_date       
##      <dbl> <chr>          <chr>             <chr>    <chr>   <dttm>             
##  1  760161 Orphan: First… en                After e… "There… 2022-07-27 00:00:00
##  2  760741 Beast          en                A recen… "Fight… 2022-08-11 00:00:00
##  3  882598 Smile          en                After w… "Once … 2022-09-23 00:00:00
##  4  717728 Jeepers Creep… en                Forced … "Evil … 2022-09-15 00:00:00
##  5  772450 Presencias     es                A man w…  <NA>   2022-09-07 00:00:00
##  6 1014226 Sonríe         es                <NA>      <NA>   2022-08-18 00:00:00
##  7  913290 Barbarian      en                In town… "Some … 2022-09-08 00:00:00
##  8  830788 The Invitation en                After t… "You a… 2022-08-24 00:00:00
##  9  927341 Hunting Ava B… en                Billion… "\"If … 2022-04-01 00:00:00
## 10  762504 Nope           en                Residen… "What’… 2022-07-20 00:00:00
## # ℹ 32,744 more rows
## # ℹ 14 more variables: title <chr>, popularity <dbl>, revenue <dbl>,
## #   budget <dbl>, poster_path <chr>, vote_count <dbl>, vote_average <dbl>,
## #   runtime <dbl>, status <chr>, adult <lgl>, backdrop_path <chr>,
## #   genre_names <chr>, collection <chr>, collection_name <chr>

Introduction

Questions

Variation

Visualizing distributions

ggplot(data = data) +
  geom_bar(mapping = aes(x = original_language))

ggplot(data = data) +
  geom_histogram(mapping = aes(x = vote_count))
## `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
## Warning: Removed 215 rows containing non-finite outside the scale range
## (`stat_bin()`).

Typical values

ggplot(data = data, mapping = aes(x = vote_count)) +
  geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
## Warning: Removed 215 rows containing non-finite outside the scale range
## (`stat_bin()`).

Unusual values

data %>%
    ggplot(aes(vote_count)) +
    geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
## Warning: Removed 215 rows containing non-finite outside the scale range
## (`stat_bin()`).

Missing Values

data2 <- data %>% 
  mutate(y = ifelse(vote_count < 100 | vote_count > 20000, NA, vote_count))

Covariation

A categorical and continuous variable

ggplot(data = data, mapping = aes(x = vote_count)) + 
  geom_freqpoly(mapping = aes(colour = vote_count), binwidth = 500)
## Warning: Removed 215 rows containing non-finite outside the scale range
## (`stat_bin()`).
## Warning: The following aesthetics were dropped during statistical transformation:
## colour.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

Two categorical variables

ggplot(data = data) +
  geom_count(mapping = aes(x = original_language, y = popularity))
## Warning: Removed 216 rows containing non-finite outside the scale range
## (`stat_sum()`).

Two continous variables

ggplot(data = data) +
  geom_point(mapping = aes(x = popularity, y = revenue))
## Warning: Removed 287 rows containing missing values or values outside the scale range
## (`geom_point()`).

Patterns and models

ggplot(data = data) + 
  geom_point(mapping = aes(x = popularity, y = vote_average))
## Warning: Removed 269 rows containing missing values or values outside the scale range
## (`geom_point()`).