[英]How to calculate the 90th percentile of a column corresponding to another column having same characters using R
df<-read. csv("input. csv")
df
So my dataframe df looks like this...
Name Time
Launch 10
Launch 20
Launch 30
Login 55
Login 69
Login 48
Login 74
Logout 29
Logout 13
Basically what I want is to add another column to my dataframe and it should hold 90th percentile of column"Time" wrt column "Name" 基本上我想要的是在我的数据框中添加另一列,它应该容纳列“时间”的90%,而列“名称”
My expected output should look like.. 我的预期输出应该看起来像..
Name 90thpercentile-_Time
Launch 90thpercentile(10,20,30)
Login 90thpercentile(55,69,48,74)
Logout 90thpercentile(29,13)
I tried a lot using R by using functions like quantile, aggregate but I did not get the expected result. 我通过使用分位数,聚合等函数在R上进行了很多尝试,但没有得到预期的结果。 Could someone help please???
有人可以帮忙吗???
aggregate(df$Time, by=list(Name=df$Name), FUN=function(x) quantile(x, probs =0.9))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.