How to Run Your Favorite Python Package in R
summary
Shows exactly how to embed Python into R using reticulate and a Python virtualenv called tweetenv, setting R to use Python 3.7 and pip installing requests. Uses a YAML secret file to load a bearer token, builds a Python header dict via json.loads, calls Twitter Labs recent search for the past seven days, receives JSON, converts it with jsonlite flattening, and pipes into dplyr to select tweet id and text, returning the default last 10 tweets for inspection.
AI-written summary · about
chapters (8)
- 0:00Start
- 0:05Running your favorite Python package inside of R
- 0:48Reticulate is a package for R that allows you to run Python code inside of R.
- 1:54The search-tweets-python example
- 2:55I'll be using the Python Requests package to make an http request to call the recent search endpoint
- 3:11Recent search allows you to get Tweets from the past seven days.
- 3:42You will also need to enroll in the preview for Labs recent search.
- 9:34If you are building with the Twitter API, I'd love to have a conversation.
related talks
32mInterfacing R and Python
22mUsing Python & R in Harmony
18mYes, you can use Python with RStudio Team!
35mEffective Python and R collaboration
18mYes, you can use Python with RStudio Team!
17mPolyglot Data Science: Why and How to Combine R and Python
21mWhen R Met Python: A Meet Cute on Posit Connect
37mRewriting your R analysis code in Python
