Visualiza las variables a trabajar
print(n=10, Data)
## # A tibble: 664 × 72
## dum abr id countrycode country currency_unit year rgdpe rgdpo pop
## <dbl> <chr> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 1 Aus 5 AUS Austra… Australian D… 1950 113607 103014 8.39
## 2 1 Aus 5 AUS Austra… Australian D… 1960 150407 149499 10.5
## 3 1 Aus 5 AUS Austra… Australian D… 1961 154037 153787 10.8
## 4 1 Aus 5 AUS Austra… Australian D… 1962 163222 162300 11.0
## 5 1 Aus 5 AUS Austra… Australian D… 1963 177064 173808 11.2
## 6 1 Aus 5 AUS Austra… Australian D… 1964 185150 182567 11.4
## 7 1 Aus 5 AUS Austra… Australian D… 1965 187981 184847 11.6
## 8 1 Aus 5 AUS Austra… Australian D… 1966 200533 197652 11.8
## 9 1 Aus 5 AUS Austra… Australian D… 1967 208644 206638 12.0
## 10 1 Aus 5 AUS Austra… Australian D… 1968 225679 222428 12.3
## # ℹ 654 more rows
## # ℹ 62 more variables: emp <dbl>, avh <dbl>, hc <dbl>, ccon <dbl>, cda <dbl>,
## # cgdpe <dbl>, cgdpo <dbl>, cn <dbl>, ck <dbl>, ctfp <dbl>, cwtfp <dbl>,
## # rgdpna <dbl>, rconna <dbl>, rdana <dbl>, rnna <dbl>, rkna <dbl>,
## # rtfpna <dbl>, rwtfpna <dbl>, labsh <dbl>, irr <dbl>, delta <dbl>, xr <dbl>,
## # pl_con <dbl>, pl_da <dbl>, pl_gdpo <dbl>, i_cig <chr>, i_xm <chr>,
## # i_xr <chr>, i_outlier <chr>, i_irr <chr>, cor_exp <dbl>, statcap <dbl>, …
head(Data$kl) ## Composición de capital (logaritmica)
## [1] 98955.13 125552.80 128757.90 130660.90 132042.40 133552.60
head(Data$tp) ## Tasa de plusvalia (logartimica)
## [1] 0.4695250 0.4581107 0.4694602 0.4911219 0.5112565 0.4965848
Desarrolla la estetica de la grafica con ggplot.
p = ggplot(Data, aes(x = kl, y = tp, size = pop, colour = country)) + geom_point(show.legend = FALSE, alpha = 0.7) +
scale_color_viridis_d() + scale_size(range = c(2, 15)) + labs(x = "(K/L)", y = "tasa de plusvalÃa") +
theme(plot.title = element_text(color = "black", size = 16, face = "bold.italic"), axis.title.x = element_text(color = "black", size = 16, face = "bold"), axis.title.y = element_text(color = "black", size = 16, face = "bold"))
Grafiquemos por pais, como por ejemplo USA.
Data_USA = subset(Data, country == "United States")
p2 = ggplot(Data_USA, aes(x = kl, y = tp, size = pop, colour = country)) + geom_point(show.legend = FALSE, alpha = 0.7) +
scale_color_viridis_d() + scale_size(range = c(2, 15)) + labs(x = "(K/L)", y = "tasa de plusvalÃa") +
theme(plot.title = element_text(color = "black", size = 16, face = "bold.italic"), axis.title.x = element_text(color = "black", size = 16, face = "bold"), axis.title.y = element_text(color = "black", size = 16, face = "bold"))
animacion_plot = p2 +
transition_time(year) +
labs(title = "Dispersión TP y K/L para USA PWT 9.1. Year: {frame_time}") +
shadow_wake(wake_length = 0.8, alpha = TRUE)
animate(animacion_plot)

Grafico interactivo para ver paises
p3 = ggplot(Data, aes(x = kl, y = tp, size = pop, colour = country)) +
geom_point(show.legend = FALSE, alpha = 0.7) + scale_color_viridis_d() + scale_size(range = c(2, 15)) +
labs(x = "(K/L)", y = "tasa de plusvalÃa") + theme(plot.title = element_text(color = "black", size = 16, face = "bold.italic"), axis.title.x = element_text(color = "black", size = 16, face = "bold"), axis.title.y = element_text(color = "black", size = 16, face = "bold"))
ggplotly(p3)
Q=plot_ly(Data, x = ~kl, y = ~tp, size = ~pop, color = ~country,
frame = ~year, type = 'scatter', mode = 'markers',
marker = list(opacity = 0.7, sizemode = 'diameter')) %>%
layout(title = "Dispersión TP y K/L. 82 paÃses. 1950-2017. PWT 9.1",
xaxis = list(title = "Ln (K/L)"),
yaxis = list(title = "Ln tasa de plusvalÃa"))
Q
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors