1 of 1 people found this helpful
Thanks for your interest in combining Tableau and R! The most critical part in leveraging that combination is a solid understanding of the flow of your data from Tableau into R and back to Tableau. There is some great material out there that should teach you all the details:
- Brief introductory video on how to setup and use the R integration in Tableau: How to Integrate R and Tableau
- Recording of a Breakout Session on the topic delivered at TC17: http://tclive.tableau.com/Library/Video?vCode=17BI-07
- Materials from a Hands-On Training on the topic I delivered at TC17: http://cdn.tri-digital.com/Tableau/2017/resources/17HI-033_ZIP_RYouReady.zip
As for your specific problem I built an example workbook that should hopefully clarify the process. This is the main piece, the calculated field containing the R code I wrote based on your screenshot from R Studio:
word <- data.frame(word = .arg1, stringsAsFactors = FALSE)
sentiment <- word %>% left_join(get_sentiments("bing"))
Note the use of .arg1 to reference the data coming from Tableau - here a vector containing MAX([Word]) - and the use of return() to send the result back to Tableau.
Please note that loading the packages inside the ad-hoc code is not really best practice, since it will have a negative effect on your performance - this is just to show the concept.
Let me know how this worked for you!
Thank you for your previous Answer, now i am planning to take count of every result.
in R - query i am able to get the out put but i am unable to retrieve the code into tableau using SCRIPT Functions.
Can you please help me.
Thank you in advance!!!
I'm not sure I fully understood what you're trying to do, but if all you need is the count of how many times each word appears in your corpus, why not just do this aggregation in Tableau? No R code is needed to achieve that. If you want to you could then run the sentiment analysis on that pre-aggregated table of distinct words in order to find out the sentiment of, say, the 20 most common words.
Does that make sense?