[This article was first published on r-bloggers on Programming with R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

R + Py

In the word of R vs Python fights, This is a simple (could be called, naive as well) attempt to show how we can combine the power of Python with R and create a new superpower.

Like this one, If you have watched The Incredibles before!

This dataset contains a bunch of tweet that came with this tag #JustDoIt after Nike released the ad campaign with Colin Kaepernick that turned controversial.

Superstar – Reticulate

The superstar who’s making this possible is the R package reticulate by RStudio.

The R Code

#loading required R libraries
library(tidyverse)
library(ggthemes)
library(knitr)
py$pos_df %>% count(pos) %>% ggplot() + geom_bar(aes(pos,n), stat = "identity") + coord_flip() + theme_minimal() + labs(title = "POS Tagging", subtitle = "NLP using Python space - Graphics using R ggplot2") Now, Again The Python Code ent_df = pd.DataFrame(columns = ["text","label"]) for ent in doc.ents: df1 = pd.DataFrame({"text" : ent.text, "label" : ent.label_}, index = [0]) #print(token.text, token.pos_) #print(df1) ent_df = pd.concat([ent_df,df1]) One Final Time, The R Code py$ent_df %>%
count(label) %>%
ggplot() + geom_bar(aes(label,n), stat = "identity") +
coord_flip() +
#theme_solarized() +
theme_fivethirtyeight() +
labs(title = "Entity Recognition",
subtitle = "NLP using Python space - Graphics using R ggplot2")

Summary

Thus, In this post we learnt how to combine the best of R and Python - in this case - R for Data Analysis and Data Visualization - Python for Natural Languge Processing with Spacy.

If you liked this, Please subscribe to my Language-agnostic Data Science Newsletter and also share it with your friends!

To leave a comment for the author, please follow the link and comment on their blog: r-bloggers on Programming with R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)