Package Review: TikTokRmd

Package Review: TikTokRmd

Below is a quick tutorial showing how to use the tiktokrmd package to display TikTok videos in .Rmd files and then serve them up on GitHub pages.

Late last week, Garrick Aden-Buie announced a new package that allows us to embed TikTok videos into R Markdown files. The package is called tiktokrmd and can be found here. It should also be noted that Garrick, has a number of other fun samples and packages on his website, that I highly encourage y’all to check out.


Install The Package

Installing the package is straight forward through the install_github() function in the remotes package. This happened to be the first new package I downloaded from GitHub on a repo that was created since the default branch was named main, so I encountered the need to employ one of two techniques below.

  1. You can just update the remotes package as Garrick pointed out.

  2. You can specify the branch as @main as I mentioned in a tweet.

#1) Update remotes to find the default branch
#install.packages("remotes")
#library(remotes)
#remotes::install_github("gadenbuie/tiktokrmd")

#2) Or if you have the remotes package installed and don't want to or can't re-install, you can just specify the branch
#remotes::install_github("gadenbuie/tiktokrmd@main")
library(tiktokrmd)


Embed Your Favorite TikTok video

This is probably the easiest tutorial I’ve written, just because of how simple Garrick has made his package. As per the instructions on his GitHub repo, simply set a variable to the TikTok video URL, pass it through the tiktok_embed() function to display the embedded video.

For my example, I am including my favorite data TikTok by Chelsea Parlett. I also highly encourage y’all to check out her videos!

tt_url <- "https://www.tiktok.com/@chelseaparlettpelleriti/video/6811647290709757189"
tt <- tiktok_embed(tt_url)
tt

You can see the hosted .Rmd html output with an embedded TikTok video here!

Knit To HTML And Host Online

In the repo, Garrick points out that the html file needs to be hosted somewhere to fully display the video. Luckily GitHub pages has us covered.

Just follow the steps in my previous blog here to host your html, .Rmd output on GitHub pages.


Thank You

Thank you for following along. The hosted output is here and the .Rmd file for this repo is here. If you replicate these steps, you can host TikTok videos in .Rmd on your own!

Explore Your Dataset in R

Explore Your Dataset in R

First Inaugural Data Mishaps Night

First Inaugural Data Mishaps Night