简体   繁体   English

如何使用R计算与具有相同字符的另一列对应的一列的第90个百分位数

[英]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.

相关问题 R:如何根据另一列分组的数据帧中的前几行为第90个分位数创建新列? - R: How to create a new column for 90th quantile based off previous rows in a data frame grouped by another column? 计算数据框中各列的百分之九十 - Calculate 90th percentile across columns in a data frame R:如何根据数据框中的前几行为第90个分位数创建新列 - R: How to create a new column for 90th quantile based off previous rows in a data frame 将第 1/3 个四分位数和第 90 个百分位数添加到 R 中的折线图 - Adding 1st/3rd quartile and 90th percentile to a line chart in R 来自每日数据的年平均值、最小值、最大值、第 90 个百分位数和第 10 个百分位数 - yearly mean, min, max, 90th percentile, and 10th percentile from daily data 如何使用R计算在同一数据帧中具有相同列名的列之间的差异 - How to calculate difference between columns having same column names in same dataframe using R 计算R中数据帧中每列的百分位数 - Calculate percentile for every column in a data frame in R 如何计算与R中另一列中的每个值相对应的列中每个值的频率? - How to calculate the frequency of each value in a column corresponding to each value in another column in R? 如何使用另一列计算 r 中的时间序列列? - How to calculate time-series column in r using another column? 如何计算R中的百分位数? - How to calculate percentile in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM