RSS feeds have actually been around since the late ’90s, and they remain a helpful way to stay up to date with multiple news sources. Choose your feeds carefully, and your RSS reader will let you easily scan headings from several sources and keep up to date on fast-moving subjects. And while there are a number of capable commercial and open-source RSS readers available, it’s a lot more pleasing to code your own.It’s remarkably easy to develop your own RSS feed reader in R. Simply follow these eight steps.Create a Quarto document or R script file You can use a plain R script, however
Quarto adds some useful, out-of-the-box styling. Book also gives you much easier access to utilizing JavaScript for the final screen if you so choose. However the guide code works fine in an R file, too.Unlike an R script, however, my Book document needs a YAML header to
start. I’ll add a couple of settings in the YAML to produce a single HTML file (embed-resources: true ), and not show my code( echo: incorrect )or any code messages or cautions:– title:”Sharon’s RSS Feed” format: html embed-resources: real editor:
source perform: echo: false caution:
false message: false– Load required plans Next, I’ll include
some R code inside an R code block(“‘
r and “‘enclose a block of executable code in Book; you don’t require those if you’re utilizing a plain R script) and load the packages I’ll require. As you might guess from its name, tidyRSS is a library for reading RSS feeds into R. ” library (tidyRSS)library( dplyr )library(DT )library( purrr)library (stringr)library (lubridate )”‘Add RSS feeds Choosing appropriate feeds is an essential part of a beneficial RSS
reader experience. I discover mine based
on sources I like and after that examining sites or browsing to see if RSS feeds
exist.(As an optional exercise, you can use the rvest bundle to check out sitemaps and wrangle them into RSS format, however that’s beyond the scope of this tutorial. Possibly in a future post!) You may want to keep your feeds in a different CSVor Excel file and have your app import them. In this manner, you don’t need to touch the app code each time you update your feed list. For the sake of demo
simpleness here, however, I’ll produce a data frame in my script file with the feeds I want and my titles for each.Since I compose for both InfoWorld and Computerworld I’ll include both of those feeds. In addition, I’ll pull in a couple of R-specific RSS feeds, including R-Bloggers, R Weekly, and Mastodon’s #rstats and #QuartoPub RSS feeds at fosstodon.org, the Mastodon
circumstances I use. In the code below, I conserve the feed details to an information frame call myfeeds with both feed URLs and my desired title for each feed. I then arrange them by feed title:”‘ myfeeds organize(feed_title) “‘ Keep in mind: From here on, I will not be including the “‘ “‘Quarto code”fences “around the R code. All the rest of the R code still requires to be”fenced”in a Book doc, however.
Source