lazyeval

How to feed a list of unquoted column names into `lapply` (so that I can use it with a `dplyr` function)

血红的双手。 提交于 2019-12-03 17:15:34
问题 I am trying to write a function in tidyverse/dplyr that I want to eventually use with lapply (or map ). (I had been working on it to answer this question, but came upon an interesting result/dead-end. Please don't mark this as a duplicate - this question is an extension/departure from the answers that you see there.) Is there 1) a way to get a list of quoted variables to work inside a dplyr function (and not use the deprecated SE_ functions) or is there 2) some way to feed a list of unquoted

How to feed a list of unquoted column names into `lapply` (so that I can use it with a `dplyr` function)

耗尽温柔 提交于 2019-12-03 06:20:08
I am trying to write a function in tidyverse/dplyr that I want to eventually use with lapply (or map ). (I had been working on it to answer this question , but came upon an interesting result/dead-end. Please don't mark this as a duplicate - this question is an extension/departure from the answers that you see there.) Is there 1) a way to get a list of quoted variables to work inside a dplyr function (and not use the deprecated SE_ functions) or is there 2) some way to feed a list of unquoted strings through an lapply or map I have used the Programming in Dplyr vignette to construct what I

How to pass column name in ggplot facet_wrap in a function

两盒软妹~` 提交于 2019-12-02 17:16:34
问题 How to pass column name of a data frame in ggplot facet_wrap or fill/colour in a function? I looked up lazyeval but didn't figure out a way. x="class" ggplot(mpg, aes(displ, hwy, col=x)) + geom_point() + facet_wrap(x) In this example, why didn't the points get coloured by x? 回答1: I used an example from ggplot2::facet_wrap . So, you can easily replace ~class with x containing a character or a formulae. Example : library(ggplot2) x="class"#or ~class ggplot(mpg, aes(displ, hwy)) + geom_point() +

How to pass column name in ggplot facet_wrap in a function

折月煮酒 提交于 2019-12-02 08:13:44
How to pass column name of a data frame in ggplot facet_wrap or fill/colour in a function? I looked up lazyeval but didn't figure out a way. x="class" ggplot(mpg, aes(displ, hwy, col=x)) + geom_point() + facet_wrap(x) In this example, why didn't the points get coloured by x? I used an example from ggplot2::facet_wrap . So, you can easily replace ~class with x containing a character or a formulae. Example : library(ggplot2) x="class"#or ~class ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_wrap(x) Have you tried ggplot(mpg, aes(displ, hwy, col=as.factor(x))) + geom_point() + facet_wrap(~x)