dgrtwo / tidy-text-mining

Manuscript of the book "Tidy Text Mining with R" by Julia Silge and David Robinson
http://tidytextmining.com
Other
1.32k stars 806 forks source link

Chapter 2 - bing _and_nrc #30

Closed t1ber1us closed 7 years ago

t1ber1us commented 7 years ago

Hi, Working from the web version of your book, and looking forward to getting a 'real' copy when it is out.

In chapter 2, when you are doing sentiment analysis on pride and prejudice, you create a joint bing_and_nrc vector, but the code seems to go awry at the end of the line :

mutate(method="Bing et al."), because of the ',' on the end (screenshot of code also attached).

I have managed to get a working version by separating the two variables, but can see your version is more elegant. How should this code look?

Thanks,

code segment
juliasilge commented 7 years ago

Hello! The online version of this book is generated with the actual code you see on the website via R Markdown and bookdown; you can see how that works here in this very repo. :smiley:

So we know that the code on the website works; you can see the the R Markdown file here. Probably there is some issue in how you are copying or translating the code?

t1ber1us commented 7 years ago

Thanks. I see now where I was going wrong (it was a knock-on effect, the bind_rows command of the first line doesn't have a closing bracket, Rstudio screamed as I entered it so I 'fixed' it by inserting one, meaning that the comma on the 'mutate' line threw up an error as R wasn't expecting one there. I clearly need to go and read more about the pipe and the way you use it here, and then will get to understanding the way the code here works. Thanks again.

juliasilge commented 7 years ago

It is a complicated bit of pipes/code right there, for sure. :pensive: One resource I really like for dplyr and the pipe (you may already know about it) is Garrett and Hadley's book available online.

sugs01 commented 7 years ago

The function of bind_rows is use to connect two tables with the same names. For example, bind_rows(data1, data2). So, a comma is requred.