This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# === Opci n 1: Descargar de WDI (requiere internet) ===
wdi <- WDI(
country = "all",
indicator = c(
gdp_pc = "NY.GDP.PCAP.KD",
cons_pc = "NE.CON.PRVT.PC.KD"
),
start = 2015,
end = 2023
) %>%
as_tibble() %>%
filter(!is.na(gdp_pc), !is.na(cons_pc))
df <-wdi %>%
group_by(iso2c) %>%
filter(year==max(year)) %>%
ungroup()
You can also embed plots, for example:
## # A tibble: 224 × 8
## country iso2c iso3c year gdp_pc cons_pc lgdp lcons
## <chr> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl>
## 1 Africa Eastern and Southern ZH AFE 2023 1413. 949. 7.25 6.86
## 2 Albania AL ALB 2023 5445. 3872. 8.60 8.26
## 3 Algeria DZ DZA 2023 4660. 1867. 8.45 7.53
## 4 American Samoa AS ASM 2022 13709. 10347. 9.53 9.24
## 5 Angola AO AGO 2023 2335. 1343. 7.76 7.20
## 6 Arab World 1A ARB 2023 6321. 3467. 8.75 8.15
## 7 Argentina AR ARG 2023 12933. 8672. 9.47 9.07
## 8 Armenia AM ARM 2023 5197. 3563. 8.56 8.18
## 9 Aruba AW ABW 2015 27458. 15194. 10.2 9.63
## 10 Australia AU AUS 2023 61598. 33827. 11.0 10.4
## # ℹ 214 more rows
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
##
## Call:
## lm(formula = cons_pc ~ gdp_pc, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19495.3 -1119.0 -512.6 791.8 14624.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.430e+03 2.739e+02 5.222 4.07e-07 ***
## gdp_pc 4.439e-01 1.056e-02 42.025 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3247 on 222 degrees of freedom
## Multiple R-squared: 0.8883, Adjusted R-squared: 0.8878
## F-statistic: 1766 on 1 and 222 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = lcons ~ lgdp, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.8442 -0.1190 0.0037 0.1449 0.6026
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.46726 0.09516 4.91 1.76e-06 ***
## lgdp 0.89318 0.01064 83.94 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2202 on 222 degrees of freedom
## Multiple R-squared: 0.9695, Adjusted R-squared: 0.9693
## F-statistic: 7046 on 1 and 222 DF, p-value: < 2.2e-16
log se ajusta mejor