全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3994 3
2016-02-06
如图所示,请问我怎么在R 中得到 cumulative percent ,特别是我有10几个变量,谢谢!
Untitled.png



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2016-2-6 05:37:57
I'm not sure whether this is what you want

a = c(1:10)
a/sum(a) # percentage
cumsum(a)/sum(a) #cumulative percentage
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-2-6 07:15:17
cocopig331 发表于 2016-2-6 05:37
I'm not sure whether this is what you want

a = c(1:10)
好像不对啊,为什么分母是 sum(a) 呢?
What if the data is like this:
a <- data.frame(sample(1:100,20),rnorm(20),rnorm(20))

How could you get the cumulative percent for each variable in the data frame?

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-2-6 07:50:32
calsunny 发表于 2016-2-6 05:25
如图所示,请问我怎么在R 中得到 cumulative percent ,特别是我有10几个变量,谢谢!
cumsum(percent)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群