Carrengado bibliotecas:
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(flextable)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.2
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ stringr 1.4.1
## ✔ tidyr 1.2.1 ✔ forcats 0.5.2
## ✔ readr 2.1.3
## Warning: package 'ggplot2' was built under R version 4.2.2
## Warning: package 'forcats' was built under R version 4.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ purrr::compose() masks flextable::compose()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(tibble)
library(tidyr)
library(forcats)
library(knitr)
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.2.2
library(ggplot2)
library(readr)
arte_MOMA <- read_delim("C:/Users/pimen/OneDrive/Documentos/7periodo/bases_curso_estatistica/Base_de_dados-master/arte_MOMA.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
## New names:
## Rows: 2253 Columns: 24
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: ";" chr
## (6): title, artist, artist_bio, artist_gender, classification, department dbl
## (8): ...1, artist_birth_year, artist_death_year, num_artists, n_female_a... num
## (3): depth_cm, height_cm, width_cm lgl (7): circumference_cm, diameter_cm,
## length_cm, seat_height_cm, purchase,...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
View(arte_MOMA)
1)Quantas pinturas existem no MoMA? Quantas variáveis existem no banco de dados?
arte_MOMA %>% nrow()
## [1] 2253
arte_MOMA %>% ncol()
## [1] 24
Resposta: Há 2253 pinturas e 19 variáveis.
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
nrow()
## [1] 2
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
filter(row_number() == 1) %>%
pull(year_acquired)
## [1] 1930
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
pull(title) %>%
first()
## [1] "House by the Railroad"
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
pull(title) %>%
last()
## [1] "Seated Nude"
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
pull(artist) %>%
first()
## [1] "Edward Hopper"
arte_MOMA %>%
filter(year_acquired == min(year_acquired, na.rm = T)) %>%
pull(artist) %>%
last()
## [1] "Bernard Karfiol"
Resposta: Duas pinturas, foram adquiridas em 1930, a “House by the Railroad” criada pelo artista Edward Hopper e a “Seated Nude” criada pelo artista Bernard Karfiol.
arte_MOMA %>%
filter(year_created == min(year_created, na.rm = T)) %>%
pull(artist)
## [1] "Odilon Redon"
arte_MOMA %>%
filter(year_created == min(year_created, na.rm = T)) %>%
pull(title)
## [1] "Landscape at Daybreak"
Resposta: A pintura mais antiga foi criada em 1872 pelo artista Odilon Redon e se chama “Landscape at Daybreak”.
tabela_artistas = table(arte_MOMA$artist)
linhas = nrow(tabela_artistas)
linhas
## [1] 989
Reposta: 898 Artistas distintos.
arte_MOMA %>%
count(artist) %>%
arrange(-n) %>%
pull(artist) %>%
first()
## [1] "Pablo Picasso"
arte_MOMA %>%
count(artist) %>%
arrange(-n) %>%
pull(n) %>%
first()
## [1] 55
Resposta: Pablo Picasso, com um total de 55 pinturas.
arte_MOMA %>%
count(artist_gender)
## # A tibble: 3 × 2
## artist_gender n
## <chr> <int>
## 1 Female 252
## 2 Male 1991
## 3 <NA> 10
arte_MOMA %>%
count(artist_gender, artist) %>%
count(artist_gender)
## # A tibble: 3 × 2
## artist_gender n
## <chr> <int>
## 1 Female 143
## 2 Male 837
## 3 <NA> 9
arte_MOMA %>%
count(year_acquired) %>%
arrange(-n) %>%
pull(n) %>%
first()
## [1] 86
arte_MOMA %>%
count(year_acquired) %>%
arrange(-n) %>%
pull(year_acquired) %>%
first()
## [1] 1985
Resposta: O número máximo foi de 86 pinturas adquiridas no ano de 1985.
arte_MOMA %>%
count(year_created) %>%
arrange(-n) %>%
pull(n) %>%
first()
## [1] 57
arte_MOMA %>%
count(year_created) %>%
arrange(-n) %>%
pull(year_created) %>%
first()
## [1] 1977
Resposta: O maior ano foi 1977 com 57 pinturas criadas.
arte_MOMA %>% group_by(year_acquired) %>%
filter(year_acquired == min(year_acquired))%>%
filter(artist_gender=="Female")%>% summarise(year_acquired,title,artist,year_created)
## `summarise()` has grouped output by 'year_acquired'. You can override using the
## `.groups` argument.
## # A tibble: 252 × 4
## # Groups: year_acquired [68]
## year_acquired title artist year_…¹
## <dbl> <chr> <chr> <dbl>
## 1 1937 Landscape, 47 "Natalia Goncharova" 1912
## 2 1938 Shack "Loren MacIver" 1934
## 3 1940 Hopscotch "Loren MacIver" 1940
## 4 1941 Shadows with Painting "Irene Rice Pereira" 1940
## 5 1941 Figure "Varvara Stepanova" 1921
## 6 1942 Still Life in Red "Amelia Pel\xe1ez Del … 1938
## 7 1942 White Lines "Irene Rice Pereira" 1942
## 8 1942 Musical Squash "Maud Morgan" 1942
## 9 1942 Desolation "Raquel Forner" 1942
## 10 1943 Self-Portrait with Cropped Hair "Frida Kahlo" 1940
## # … with 242 more rows, and abbreviated variable name ¹year_created
Resposta: A primeira pintura de uma artista mulher foi “Landscape”, adquirida em 1937 da artista Natalia Goncharova e criada em 1912.
arte_MOMA %>%
mutate(idade = artist_death_year - artist_birth_year) %>%
arrange(-idade) %>%
pull(artist) %>%
first()
## [1] "Dorothea Tanning"
arte_MOMA %>%
mutate(idade = artist_death_year - artist_birth_year) %>%
arrange(-idade) %>%
pull(idade) %>%
first()
## [1] 102
Resposta: A artista foi Dorothea Tanning que viveu por 102 anos.
arte_MOMA %>%
mutate(idade = artist_death_year - artist_birth_year) %>%
summarise(media = mean(idade, na.rm = T)) %>%
pull(media) %>%
format(., digits = 1)
## [1] "75"
arte_MOMA %>%
mutate(idade = artist_death_year - artist_birth_year) %>%
group_by(artist_gender) %>%
summarise(media = mean(idade, na.rm = T)) %>%
mutate(media = format(media, digits = 3)) %>%
kable()
| artist_gender | media |
|---|---|
| Female | 74.0 |
| Male | 74.7 |
| NA | 72.0 |
moma_dim <- arte_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")