Ejercicio 1

library("data.table")
library("ggrepel")
library("ggthemes")
library("maps")
library("gganimate")
library("GGally")
library("gifski")
library("transformr")
library("tidyverse")

setwd("C:/INFORMATICA 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()

Ejercicio 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")

EJERCICIO 3

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

EJERCICIO 4

library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(rgeos)

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)

EJERCICIO 5

library(tidyverse)

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)

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