我有一个多列的数据框。我想用百分比创建一个新的列。我没有正确的输出,有什么建议吗?
il.count.descrition elle.count.description un.count.description Words.count
5 1 5 563
9 2 2 65
1 1 4 100
10 9 0 89
data %>% mutate(il.count.ratio = il.count.description / Words.count * 100,
elle.count.ratio = elle.count.description / Words.count * 100,
un.count.ratio = un.count.description / Words.count * 100)
你可以试试这个,它对我有用。也许错误是因为您在第一个变量名中有错字。
data <- data %>% mutate(il.count.ratio = round(il.count.descrition / Words.count * 100,1),
elle.count.ratio = round(elle.count.description / Words.count * 100,1),
un.count.ratio = round(un.count.description / Words.count * 100,1))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句