I need to build a "profile" of a data set, showing the number of data entries that lie between two values. I have been able to achieve the result using the "group_by" function, however the resultant output is not in a format that I can use further down my workflow. Here is that output:
What I need, is something that looks like this:
The "Data Count" column, I've not been able to populate but is there for illustration.
The code I am using is as follows;
library(formattable)
PML_Start = 0
PML_Max = 100000000
PML_Interval = 5000000
Lower_Band <- currency(seq(PML_Start, PML_Max-PML_Interval, PML_Interval),digits=0)
Upper_Band <- currency(seq(PML_Start+PML_Interval,PML_Max,PML_Interval),digits = 0)
PML_Profile <- data.frame("Lower Band"=Lower_Band,"Upper Band"=Upper_Band,"Data Count")
I know cannot figure out how to further populate this table. I gave this a go, but didn't really believe it would work.
PML_Profile <- Profiles_on_Data_Provided_26_9_17 %>%
group_by (Lower_Band) %>%
summarise("Premium" = sum(Profiles_on_Data_Provided_26_9_17$`Written Premium - Total`))
Any thoughts?