We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have wrote three functions as according to the official guidelines in Using ggplot2 in packages.
#' @importFrom ggplot2 ggplot geom_boxplot aes myplot1 = function(data, x = "group", y = "weight"){ ggplot(data, aes({{ x }}, {{ y }})) + geom_boxplot() } #' @importFrom ggplot2 ggplot geom_boxplot aes_string myplot2 = function(data, x = "group", y = "weight"){ ggplot(data, aes_string(x, y)) + geom_boxplot() } #' @importFrom ggplot2 ggplot geom_boxplot aes #' @importFrom rlang .data myplot3 = function(data, x = "group", y = "weight"){ ggplot(data, aes(.data[[x]], .data[[y]])) + geom_boxplot() }
All these functions are designed to have identical results. However, they don't.
data("PlantGrowth") myplot1(PlantGrowth) myplot2(PlantGrowth) myplot3(PlantGrowth)
I'am wondering whether I am wrong with coding of myplot1(). Please give me some feedback.
myplot1()
The text was updated successfully, but these errors were encountered:
In the first case you are passing in strings which makes the call equivalent to
ggplot(data, aes("group", "weight")) + geom_boxplot()
which is not correct code
You should not pass in the aesthetics as strings but as unquoted expressions (i.e. how you would write them inside aes())
aes()
Sorry, something went wrong.
In the first case you are passing in strings which makes the call equivalent to ggplot(data, aes("group", "weight")) + geom_boxplot() which is not correct code You should not pass in the aesthetics as strings but as unquoted expressions (i.e. how you would write them inside aes())
Yes, you are right. myplot1(PlantGrowth, x = group, y = weight) works for me.
myplot1(PlantGrowth, x = group, y = weight)
Thanks for your immediate response!
No branches or pull requests
I have wrote three functions as according to the official guidelines in Using ggplot2 in packages.
All these functions are designed to have identical results. However, they don't.
I'am wondering whether I am wrong with coding of
myplot1()
. Please give me some feedback.The text was updated successfully, but these errors were encountered: