Within R, I use dplyr and more specifically arrange().
Somehow the arrange function doesn\'t work as expected.
In the example
An update is necessary to the good answer by @avid_useR because 'rlang::parse_quosure' is deprecated now.
To give a short answer to the question how to make 'dplyr::arrange' accept a string or variable containing a string for the column name to sort, you can do:
target_column = rlang::sym('mean_age')
df %>% group_by(state) %>% arrange(!!target_column)
OR as one-liner (if you only need to use it once):
df %>% group_by(state) %>% arrange(!!rlang::sym(target_column))