get percentage by multiple grouping
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a dataset that looks like the following (the following is only the first few lines)
Rate Category Status Value
1.1 A 1 500
1.7 B 0 250
1.8 C 2 1075
.....
So Rate and Value both have numerical values. Range of Rate is -5 to 5. Category has values A,B, or C. Status only takes on values 0,1,2. I want to calculate the percentage of value for each rate bucket + category bucket + "status=1". I want to divide rate bucket into a 0.5 wide discretization, that is, (-inf,0.5],(0.5,1],.... and eventually have the following table:
Rate Category %_of_status = 1(in value)
<=0.5 A 10%
0.5-1.0 A 15%
.....
For example the first %_of_status in the table above should be calculated this way: take all values where rate<=0.5 and category = A and calculate sum(value,status = 1)/sum(value)
What is the fastest way to do this? Thanks.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Language Fundamentals dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!