Punto 1

library(data.table)
library(ggrepel)
library(ggthemes)
library(maps)
library(gganimate)
library(GGally)
library(gifski)
library(transformr)
library(tidyverse)
setwd("D:/Quinto Semestre/Info para Economistas")
cel<- fread("Elections.csv")
cces<-fread("Congreso.csv")


cel %>%
  filter(congress==115) %>%
  mutate(Gender= ifelse(female==1, "Female", "Male"), Mayoria= ifelse(majority==1, "Majority", "Minority")) %>%
  ggplot(aes(Mayoria, les))+
  labs(title="LES in the 115th Congress", x= "Majority or Minority", y="Legislative Effectiveness")+
  geom_boxplot()

Punto 2

Semestre<- c(1,2,3,4,5,6,
             1,2,3,4,5,6,
             1,2,3,4,5,6)

Estudiante<- c("Carol","Carol","Carol","Carol","Carol","Carol",
               "Davis","Davis","Davis","Davis","Davis","Davis",
               "Diana","Diana","Diana","Diana","Diana","Diana")

Grado<- runif(18,min = 80, max = 100)

datos<- data.frame(Semestre, Estudiante, Grado)
ggplot(datos,aes(Semestre, Grado, color=Estudiante))+labs(title="Student Grades by Semester")+
  geom_line()+facet_grid(.~ Estudiante)+ theme(legend.position = "none")

Punto 3

cel %>%
  mutate(Gender= ifelse(female==1, "Female", "Male")) %>%
  ggplot(aes(x=year, y= votepct, fill=Gender))+
  geom_bar(stat = "identity")+labs(title="Women Participation")+
  scale_y_continuous(labels = scales::percent)+
  ggthemes::theme_fivethirtyeight()

Punto 4

library(sp)
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(rgeos)
library(tidyverse)


s_america<-ne_countries(scale="medium",continent='south america',returnclass="sf")


mapa_mundo= map_data("world")


unionp <- mapa_mundo %>%
  left_join(s_america, by = c("region"="sovereignt"))


unionp %>%
  ggplot( aes(x=long, y= lat, group=group, fill = pop_est)) +
  geom_polygon(color = "black") +
  coord_fixed (xlim= c(-115,-30),
               ylim= c(-55,15))+
  scale_fill_distiller(palette=10)

Punto 5

Category<-c("Alpha","Beta","Zeta")
City<-c("Hong Kong","London","Nairobi")

my_dat<-expand_grid(Category,City)
set.seed(84684)
my_dat$Value<-sample(1:10,9,replace=T)

grafica<-ggplot(my_dat,aes(x= Category,y=Value,fill=City))+
  geom_col()+
  transition_states(City)+
  enter_fade()+
  exit_shrink()+
  ease_aes("quadratic-in-out")
grafica