I am having a hard time manipulating a tibble output that I receive after piping (using dplyr pipe %>%) a data frame through a series of steps. This code below returns a 2 x 3 tibble ouput:
sr_df %>% group_by(ResolutionViolated) %>% tally() %>% arrange(desc(n)) %>% mutate(total = sum(n))
This gives me a count of service requests that are and aren't violated (or simply put, late). This is well and good, but I want to be able to manipulate this same tibble further without having to save the tibble as an object.
Why? Because this way, I can filter my data frame (sr_df) before this piping operations, by company/account, priority, and other factors. I am able to filter with an if function, but this filter will not have an impact on the newly created tibble object. So I am looking to do something like this:
sr_df %>% group_by(ResolutionViolated) %>% tally() %>% arrange(desc(n)) %>% mutate(total = sum(n)) %>% round(tibble[1,2]/tibble$total*100, digits = 2)
I am an R and Coding Noob. Don't hold back - I just want to learn; learn quick and learn right. Any answers are appreciated. Thank you!
I have looked at this: R: Further subset a selection using the pipe %>% and placeholder but I don't think I get it.