Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
如果没有可重现的示例,这是一项艰巨的任务。我使用gapminder数据来尝试解决您的问题:
数据
gapminder %>% select(country, year, lifeExp) %>% filter(year %in% c(1952, 1977)) %>% pivot_wider(names_from = year, values_from = lifeExp) %>% mutate(difference = abs(`1952`- `1977`))
输出
# A tibble: 142 x 4 country `1952` `1977` difference <fct> <dbl> <dbl> <dbl> 1 Afghanistan 28.8 38.4 9.64 2 Albania 55.2 68.9 13.7 3 Algeria 43.1 58.0 14.9 4 Angola 30.0 39.5 9.47 5 Argentina 62.5 68.5 6.00 6 Australia 69.1 73.5 4.37 7 Austria 66.8 72.2 5.37 8 Bahrain 50.9 65.6 14.7 9 Bangladesh 37.5 46.9 9.44 10 Belgium 68 72.8 4.8 # ... with 132 more rows
转换为您的(假定的)dataframe,可能是:
dataframe
dataframe %>% select(Year, Country, percentagecolumn) %>% filter(year %in% c(1990, 2019)) %>% pivot_wider(names_from = Year, values_from = percentagecolumn) %>% mutate(percentage_difference = abs(`1990`- `2019`))
Without a reproducible example that's a difficult task to perform. I used the gapminder data to try to solve your problem:
Data
Output
Translated to your (presumed) dataframe that might be:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
如果没有可重现的示例,这是一项艰巨的任务。我使用gapminder数据来尝试解决您的问题:
数据
输出
转换为您的(假定的)
dataframe
,可能是:Without a reproducible example that's a difficult task to perform. I used the gapminder data to try to solve your problem:
Data
Output
Translated to your (presumed)
dataframe
that might be: