I'm using example GPD over time data from gapminder:
I’m trying to interpolate years in the data so that each country contains a row for every year instead of every 5 years. I need the gdp, pop and life expectancy columns to be interpolated in the new rows added. The rank column is calculated by gdp values for each year, but the rank and height columns aren’t really relevant here.
Any help is greatly appreciated! Apologies for the newbie question, just want to make sure I’m doing this correctly.
library(tidyverse) library(gapminder) plotData <- gapminder %>% filter(continent == "Americas") %>% group_by(year) %>% mutate(rank = min_rank(-gdpPercap) * 1) %>% mutate(height = gdpPercap / max(gdpPercap)) %>% ungroup()