I'm trying to create a function that counts the values of a column that I specify in an existing dataframe. I want to select a few specific columns, group by one column (in particular), and then count the column whose name I specify in the function. I feel like this should be straightforward, but I don't know where I'm going wrong. Help would be very much appreciated!
Yaaaahoooo!!! I just tried out the first function on my dataset, and it works! Thanks so much for taking the time to comment/reply; you just saved me about 25 pages of R markdown. Very much appreciated! Thanks!
Yarnabrina's second option is the better and more "standard" one to use, since you can enter the column as a bare column name and avoid the need to use quo. Also, the latest version of dplyr now has an option that is simpler than the enquo(x)!!x pair: Instead of enquo(column) and then !!column, you can just do the single operation {{column}} each time you want to use column in a function. For example:
Also, the select step is unnecessary (unless you need to select specific columns for other things you want to do within this function), and the group_by can be combined into the count function.