Carregando a base de dados

library(dplyr)
library(ggplot2)

library(readr)
Banco_Moma <- read_delim("https://raw.githubusercontent.com/DATAUNIRIO/Base_de_dados/master/arte_MOMA.csv", delim = ";")

Atividades

Atividade 1

São 2253 pinturas (obs.) e 24 variáveis.

Atividade 2

A primeira pintura adquirida foi House by the Railroad de Edward Hopper.

Atividade 3

Landscape by daybreak de Odilon Redon.

Atividade 4

count(Banco_Moma,artist)
## # A tibble: 989 x 2
##    artist                        n
##    <chr>                     <int>
##  1 A. E. Gallatin                1
##  2 A.R. Penck (Ralf Winkler)     1
##  3 Abraham Palatnik              2
##  4 Abraham Rattner               1
##  5 Abraham Walkowitz             1
##  6 Ad Dekkers                    1
##  7 Ad Reinhardt                 10
##  8 Adam Pendleton                1
##  9 Adolf Richard Fleischmann     1
## 10 Adolph Gottlieb               9
## # … with 979 more rows

989 artistas

Atividade 5 e 6

total <- data.frame(Banco_Moma$artist,check.names = FALSE)

total %>% group_by(Banco_Moma$artist) %>% count(,sort = TRUE)
## # A tibble: 989 x 2
## # Groups:   Banco_Moma$artist [989]
##    `Banco_Moma$artist`     n
##    <chr>               <int>
##  1 Pablo Picasso          55
##  2 Henri Matisse          32
##  3 On Kawara              32
##  4 Jacob Lawrence         30
##  5 Batiste Madalena       25
##  6 Jean Dubuffet          25
##  7 Odilon Redon           25
##  8 Ben Vautier            24
##  9 Frank Stella           23
## 10 Philip Guston          23
## # … with 979 more rows
# ou

Banco_Moma %>% count(artist,sort=TRUE)
## # A tibble: 989 x 2
##    artist               n
##    <chr>            <int>
##  1 Pablo Picasso       55
##  2 Henri Matisse       32
##  3 On Kawara           32
##  4 Jacob Lawrence      30
##  5 Batiste Madalena    25
##  6 Jean Dubuffet       25
##  7 Odilon Redon        25
##  8 Ben Vautier         24
##  9 Frank Stella        23
## 10 Philip Guston       23
## # … with 979 more rows

Pablo Picasso com 55 obras

Atividade 7

Banco_Moma %>% count(artist_gender,sort=TRUE)
## # A tibble: 3 x 2
##   artist_gender     n
##   <chr>         <int>
## 1 Male           1991
## 2 Female          252
## 3 <NA>             10
# ou
table(Banco_Moma$artist_gender)
## 
## Female   Male 
##    252   1991

Atividade 8

Banco_Moma["Idade"]<-Banco_Moma$artist_death_year - Banco_Moma$artist_birth_year

Banco_Moma2=distinct(Banco_Moma,artist,.keep_all = TRUE)

table(Banco_Moma2$artist_gender)
## 
## Female   Male 
##    143    837

143 mulheres e 837 homens

Atividade 9

Banco_Moma %>% count(year_acquired,sort=TRUE)
## # A tibble: 88 x 2
##    year_acquired     n
##            <dbl> <int>
##  1          1985    86
##  2          1942    71
##  3          1979    71
##  4          1991    67
##  5          2005    67
##  6          1967    65
##  7          2008    55
##  8          1961    45
##  9          1969    45
## 10          1956    42
## # … with 78 more rows

1985

Atividade 10

Banco_Moma %>% count(year_created,sort=TRUE)
## # A tibble: 139 x 2
##    year_created     n
##           <dbl> <int>
##  1         1977    57
##  2         1940    56
##  3         1964    56
##  4         1961    50
##  5         1962    49
##  6         1963    44
##  7         1959    42
##  8         1968    40
##  9         1960    39
## 10         1914    37
## # … with 129 more rows

1977

Atividade 11

Banco_Moma %>% group_by(artist_gender) %>% summarise(ano=min(year_acquired,na.rm = TRUE))
## # A tibble: 3 x 2
##   artist_gender   ano
##   <chr>         <dbl>
## 1 Female         1937
## 2 Male           1930
## 3 <NA>           1983

Em 1937, Landscape, 47 Natalia Goncharova, 1912

Atividade 12

Banco_Moma["Idade"]<-Banco_Moma$artist_death_year - Banco_Moma$artist_birth_year

Dorothea Tanning, 102 anos

Atividade 13

summary(Banco_Moma2$Idade)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   27.00   66.00   76.00   73.78   85.00  102.00     317

73,78

Atividade 14

Banco_Moma2 %>% group_by(artist_gender) %>%
  summarise(media_vida=mean(Idade,na.rm=TRUE),
            mediana=median(Idade,na.rm=TRUE),
            desvio_padrao=sd(Idade,na.rm=TRUE),
            maior=max(Idade,na.rm=TRUE),
            n=n())
## # A tibble: 3 x 6
##   artist_gender media_vida mediana desvio_padrao maior     n
##   <chr>              <dbl>   <dbl>         <dbl> <dbl> <int>
## 1 Female              73.9      75          17.9   102   143
## 2 Male                73.8      76          14.4   101   837
## 3 <NA>                72        68          12.5    86     9

Não de forma considerável. A mediana é um ano maior mas a média é praticamente a mesma, com o desvio pedrão das mulheres um pouco sendo um pouco maior.

Gráfico fivethirtyeight

moma_dim <- Banco_Moma %>% 
  filter(height_cm < 600, width_cm < 760) %>% 
  mutate(hw_ratio = height_cm / width_cm,
         hw_cat = case_when(
           hw_ratio > 1 ~ "mais alto que largo",
           hw_ratio < 1 ~ "mais largo que alto",
           hw_ratio == 1 ~ "quadrado perfeito"
         ))
library(ggthemes)
ggplot(moma_dim, aes(x = width_cm, y = height_cm, colour = hw_cat)) +
  geom_point(alpha = .5) +
  ggtitle("Pinturas do MoMA, altas e largas") +
  scale_colour_manual(name = "",
                      values = c("gray50", "#FF9900", "#B14CF0")) +
  theme_fivethirtyeight() +
  theme(axis.title = element_text()) +
  labs(x = "Largura", y = "Altura")