I wrote the function to plot bar graph with factor variables. When I run my function,The error message was showed. Error in eval(expr, envir, enclos) : object \'dset\' not f
Converted to an answer, as it seems useful
aes
is designed to evaluate unquoted column names within the scope of the provided dataset (dset
in your case). dset[, i]
is not a column name, rather a whole column which aes
wasn't designed to deal with.
Fortunately, you can parse quoted column names to aes_string
. Thus, using
aes_string(x = names(dset)[i])
instead of
aes(x = dset[, i])
Should solve your problem