I have a straightforward code in R that gives me the number of times a username sent a ticket request.
Data is the source dataframe, and I subsetted by request type "4"
data2 <- subset(data, q_1 == '4')
data_df_2 <- count(data2, "ticket_holder_username")
data_df_2
Attached is the image of the output in RMD. (blacked out names for privacy) Output
How do I sort the output by the frequency?
How do I add another column that shows the percentage out of total tickets?
Is there a way to have a "Sum" of counts display at the bottom?
I am welcome to using a different package if it could give a neater output.
I have tried
arrange(desc())
but it gives is.data.frame(df) is not true.
EDIT:
Here's what I tried per https://stackoverflow.com/users/19340922/nan-yang suggestion:
you can use the function
group_byandsummarisein the dplyr package. In your case, you can count the frequency using this:Then you can sort it from highest to the lowest using
summariseTo add another column showing the percentage: