1

I am starting to use tidytext to get basic word frequencies for a text file with a collection of emails and lots of garbage in between.

The relevant part of the script is:

library(tidytext)

data <- read_lines("emails.txt")

text_tibble <- tibble(line = seq_along(data), text = data)

text_tibble %>%
        unnest_tokens_(word, text)

Error: Can't convert a function to a quosure

Can you please orient me? Thanks. Original data result of dput(text_tibble)

user9365328
  • 29
  • 1
  • 3
  • please provide your data in the form of `dput(text_tibble)` – acylam Mar 25 '18 at 22:20
  • This is still not optimal. What I meant is run `dput(text_tibble)` in your console and copy and paste the output into your question. Please check this question for tips on asking a reproducible question: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – acylam Mar 25 '18 at 23:15
  • I wonder if they have `unnest_token_()` in the tidytext package. Have you tried `unnest_token()`, instead? – jazzurro Mar 25 '18 at 23:53
  • Thanks jazzuro, I was not familiar with unnest_token and it worked, but I still do not know why I got the error. I guess I will have to research it later. – user9365328 Mar 26 '18 at 00:15
  • @user9365328 The package does not have `unnest_token_()'. You might have thought that the function was in the dplyr package, maybe? – jazzurro Mar 26 '18 at 00:26
  • yes I used to use that with dplyr but I swear I used it with tidytext too. Maybe I am wrong, I have not done this kind of script in some time. – user9365328 Mar 26 '18 at 00:34

1 Answers1

0

The tidytext package does have underscored versions of most functions for standard evaluation, although these are being deprecated in favor of tidyeval semantics.

The idea with the underscored versions is that they take arguments by value, not by code like the usual non-standard evaluation versions that we are mostly used to using, like with dplyr. If you wanted to use the underscored versions (which, like I said, are being deprecated) you need to pass the actual values.

text_tibble %>%
    unnest_tokens_("word", "text")
Julia Silge
  • 10,848
  • 2
  • 40
  • 48