Q1:
sorting = function (table, column) {
# mtcars[order(mpg),]
return(table[order(column),])
}
sorting(mtcars, "mpg")
is equivalent to mtcars[order("mpg"),]
but not equals to the result I want to get which is mtcars[order(mpg),]
, how can I convert it from string to column name.
Q2:
similar:
library(tidyr)
comb = function(table, colNNN, arr, sep) {
return(unite(table, colNNN, all_of(arr), sep = sep))
}
and I do
comb(mtcars,"gearCarb",c("gear","carb"), "-")
and I got colNNN
as the final column name,
so how to convert symbol into a String?