MUTATE adds new columns
So we can select some columns! But maybe we wanted some new columns - say, the total gdp?
This is a job for... mutate()
!
(
data
%>% select(
country = Country,
year = Year,
status = Status,
population_size = Population,
life_expectancy = `Life expectancy`,
infant_deaths = `infant deaths`,
under_five_deaths = `under-five deaths`,
adult_deaths = `Adult Mortality`,
gdp_per_capita = GDP
)
%>% mutate(
total_gdp_in_millions = gdp_per_capita * population_size / 1E6
)
)
Note
Before going on - save the above in a variable called reformatted