Tarea Clase 2
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.7 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.0
## ✔ readr 2.1.2 ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(readr)
Costos mundiales para tener una dieta sana
foodprice<-read.csv("/cloud/home/r1532140/R/x86_64-pc-linux-gnu-library/4.2/002065d4-ac26-4c39-a7d8-b43ef58c161e_Data.csv")
foodprice %>%
select(Country.Name, Classification.Name, Time, Cost.of.a.healthy.diet..CoHD., Cost.of.a.nutrient.adequate.diet..CoNA.) %>%
filter(Cost.of.a.nutrient.adequate.diet..CoNA. >= 1) %>%
filter(Cost.of.a.healthy.diet..CoHD. >= 1) %>%
arrange(Cost.of.a.healthy.diet..CoHD.) %>%
mutate(Precio.en.pesos.arg. = 127.99 *as.numeric(Cost.of.a.nutrient.adequate.diet..CoNA.)) %>%
group_by(Country.Name, Cost.of.a.healthy.diet..CoHD., Precio.en.pesos.arg., Cost.of.a.nutrient.adequate.diet..CoNA.) %>%
summarise(promedios.totales = mean(as.numeric(Cost.of.a.healthy.diet..CoHD., Precio.en.pesos.arg., Cost.of.a.nutrient.adequate.diet..CoNA.)))
## `summarise()` has grouped output by 'Country.Name',
## 'Cost.of.a.healthy.diet..CoHD.', 'Precio.en.pesos.arg.'. You can override using
## the `.groups` argument.
## # A tibble: 23 × 5
## # Groups: Country.Name, Cost.of.a.healthy.diet..CoHD., Precio.en.pesos.arg.
## # [23]
## Country.Name Cost.of.a.healthy.diet… Precio.en.pesos… Cost.of.a.nutri…
## <chr> <chr> <dbl> <chr>
## 1 Albania 3.952 316. 2.471
## 2 Algeria 3.763 297. 2.323
## 3 Angola 4.327 414. 3.231
## 4 Anguilla 3.717 311. 2.433
## 5 Antigua and Barbuda 4.112 386. 3.017
## 6 Argentina 3.341 336. 2.625
## 7 Armenia 3.096 283. 2.208
## 8 Aruba 3.418 363. 2.835
## 9 Australia 2.259 204. 1.595
## 10 Austria 2.772 289. 2.256
## # … with 13 more rows, and 1 more variable: promedios.totales <dbl>