tidyverse / dplyr

dplyr: A grammar of data manipulation
https://dplyr.tidyverse.org/
Other
4.77k stars 2.12k forks source link

enquo(var) followed by !!var does not work in tidytext::unnest_token #2987

Closed dan-reznik closed 7 years ago

dan-reznik commented 7 years ago

loads required libraries

library(tidyverse)
library(tidytext)

creates to 2-row tibble, test simple operation (it works)

df <- tribble(~id,~descr,1,"hello bug",2,"goodbye bug")
df %>% select(id,descr) %>% unnest_tokens(word,descr)

A tibble: 4 x 2 id word

1 1 hello 2 1 bug 3 2 goodbye 4 2 bug

creates a parametrized dplyr 0.7.* version of the above

myFn <- function(df, col1,col2) {
  col1 <- enquo(col1)
  col2 <- enquo(col2)
  df %>%  select(!!col1, !!col2) %>% # works
    unnest_tokens(word, !!col2) # this won't work
}

Call to myFn below pukes at unnest_tokens()

myFn(df,id,descr)

Error: Invalid column specification

lionel- commented 7 years ago

That's because tidytext isn't ported to tidyeval yet. Could you move the issue there please.

dan-reznik commented 7 years ago

Lionel thanks -- where should I move it to?

dan

On Fri, Jul 21, 2017 at 4:56 AM, Lionel Henry notifications@github.com wrote:

That's because tidytext isn't ported to tidyeval yet. Could you move the issue there please.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tidyverse/dplyr/issues/2987#issuecomment-316932193, or mute the thread https://github.com/notifications/unsubscribe-auth/APeqloH6DdTeBxz31tEVTW32l3V78A_5ks5sQFmigaJpZM4Oem_P .

lionel- commented 7 years ago

To the tidytext package please.

dan-reznik commented 7 years ago

thanks lionel! done! congrats on the EXCELLENT work!

On Fri, Jul 21, 2017 at 9:29 AM, Lionel Henry notifications@github.com wrote:

To the tidytext package please.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tidyverse/dplyr/issues/2987#issuecomment-316988277, or mute the thread https://github.com/notifications/unsubscribe-auth/APeqlgMM44dRb7peyH0CT4YgDqHNxboLks5sQJmagaJpZM4Oem_P .