0

Have built a custom R script for the requirement mentioned below

Our client wants their data to be displayed in Pie-chart, but the dimension we are using in pie-chart has 16 values. The requirement is to display the top 9 separately and the remaining values(16-9=7) to be grouped into one value(As Others), so that it will display all the values.

For the above req i have used

suppressPackageStartupMessages(library(googleVis))
library(dplyr)
df=data.frame(Function=(Current_Model_Salary_All_Dimensions$'Grouped Function'),Amount=c(Current_Model_Salary_All_Dimensions$Amount))
df <- df %>% group_by(Function) %>% summarise(Amount = sum(Amount)) %>% arrange(desc(Amount))
df <- rbind(top_n(df,9), slice(df,10:n()) %>% summarise(Function="Others",Amount=sum(Amount)))
plot(gvisPieChart(df,options=list(width=500, height=500)))

Screenshot:

gi

But now the small change in this, if we select Others in the pie chart , can it display what are all included in the others and their percentages.

user20650
  • 24,654
  • 5
  • 56
  • 91
Praveen
  • 1
  • 1
  • 3
  • Am I correct in understanding that your code does not do what you want as you want to add some capability to generate a summary for the 'other' category? Ps please try and create some dummy data which would allow users to reproduce your example -- this gives you a bit more chance of getting a useful asnwer. – user20650 Dec 23 '19 at 12:10
  • some hints on providing data in your question: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – user20650 Dec 23 '19 at 12:11

0 Answers0