library(tidyverse)
df <- tibble(var1 = sample(1:100,20),
var2 = sample(1:100,20),
var3 = sample(1:100,20))
# Now let's use mutate to create a fourth column and define it as the ratio of var1 / var 2:
df %>% mutate(ratio1_2 = var1/var2) %>%
# And also let's sort the table according to the ratios
arrange(ratio1_2)
1条答案
按热度按时间zengzsys1#
花些时间学习如何提出社区可以帮助你的问题。
我希望这对你来说是一个很好的解决方案: