I have a homework question: "For each age range find the percent of patients who were readmitted after 30 days and display the results in a bar chart."
I ran the following code and got "Error: n() should only be called in a data context"
cont_table_4<-diabetic_data%>%
select(age, readmitted)%>%
filter(readmitted==">30")%>%
group_by(age)%>%
summarize(count=n())%>%
arrange(desc(count()))
I used this almost the exact same format for a question: "Find out which sub-specialty has the most readmissions. Then print the breakdown for that sub-specialty by race." And it worked perfectly. I emailed my instructor a screenshot of the code and error and she said the issue is with count() function call even though the error refers to n(). I don't really know what to do with that information. I have loaded dplyr and plyr, unloaded each of them and tried again with just one of them and I get the same error message. I have looked up many Q&A regarding this error but can't find what I'm looking for. I'm a student just beginning to learn R and any help is appreciated!