R Markdown: The Definitive Guide

2.8 interactive documents.

R Markdown documents can also generate interactive content. There are two types of interactive R Markdown documents: you can use the HTML Widgets framework, or the Shiny framework (or both). They will be described in more detail in Chapter 16 and Chapter 19 , respectively.

2.8.1 HTML widgets

The HTML Widgets framework is implemented in the R package htmlwidgets ( Vaidyanathan et al. 2023 ) , interfacing JavaScript libraries that create interactive applications, such as interactive graphics and tables. Several widget packages have been developed based on this framework, such as DT ( Xie, Cheng, and Tan 2023 ) , leaflet ( Cheng, Schloerke, et al. 2023 ) , and dygraphs ( Vanderkam et al. 2018 ) . Visit https://www.htmlwidgets.org to know more about widget packages as well as how to develop a widget package by yourself.

Figure 2.7 shows an interactive map created via the leaflet package, and the source document is below:

An R Markdown document with a leaflet map widget.

FIGURE 2.7: An R Markdown document with a leaflet map widget.

Although HTML widgets are based on JavaScript, the syntax to create them in R is often pure R syntax.

If you include an HTML widget in a non-HTML output format, such as a PDF, knitr will try to embed a screenshot of the widget if you have installed the R package webshot ( Chang 2023 ) and the PhantomJS package (via webshot::install_phantomjs() ).

2.8.2 Shiny documents

The shiny package ( Chang et al. 2023 ) builds interactive web apps powered by R. To call Shiny code from an R Markdown document, add runtime: shiny to the YAML metadata, like in this document:

Figure 2.8 shows the output, where you can see a dropdown menu that allows you to choose the number of bins in the histogram.

An R Markdown document with a Shiny widget.

FIGURE 2.8: An R Markdown document with a Shiny widget.

You may use Shiny to run any R code that you like in response to user actions. Since web browsers cannot execute R code, Shiny interactions occur on the server side and rely on a live R session. By comparison, HTML widgets do not require a live R session to support them, because the interactivity comes from the client side (via JavaScript in the web browser).

You can learn more about Shiny at https://shiny.rstudio.com .

HTML widgets and Shiny elements rely on HTML and JavaScript. They will work in any R Markdown format that is viewed in a web browser, such as HTML documents, dashboards, and HTML5 presentations.

DEV Community

DEV Community

Cecilia Baggini

Posted on May 1, 2021

How to create interactive HTML reports using R

In this post, I will explain how to create interactive HTML reports including widgets such as maps and interactive graphs using R. I assume that the reader is familiar with basic R. I will use two public APIs from the Environment Agency to download data, the Water Quality Archive for water quality data (phosphate in this example) and the Rainfall API to look for rainfall monitoring locations. First, let’s load the packages we need and get the current date.

Then, we can retrieve phosphate information for two sites (Powick and Leintwardine on the River Teme, West Midlands). The information to retrieve determinand and site codes are in the documentation linked above. Once we have retrieved the data, we can rename the columns to something a bit more sensible than the original output and create a new concentration column that converts concentrations below the limit of detection to half of the limit of detection. We also add latitude and longitude columns converting from UK-specific coordinates (eastings and northings).

We then create an HTML table with site names, codes and coordinates.

Then, we search for the closest rainfall monitoring site to each of the water quality sites and put this information in another table.

At this point, we can create a map showing water quality and corresponding rainfall monitoring point.

Then we create an interactive Plotly graph that shows how phosphate changes in time at the two sites we selected.

Finally, we assemble the two tables, the map and the graph and a title in a tagList and then save it to an HTML file.

And here is the final product!

Alt Text

Top comments (0)

pic

Templates let you quickly answer FAQs or store snippets for re-use.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .

Hide child comments as well

For further actions, you may consider blocking this person and/or reporting abuse

scofieldidehen profile image

The Dark Side of AI/AGI

Scofield Idehen - Apr 2

derlin profile image

Introducing Mantelo - The Best Keycloak Admin Client for Python

Lucy Linder - Apr 2

aluisiodev profile image

Implementing end-to-end encryption (E2EE) to a Planning Poker game

Aluisio Amorim C. - Apr 2

nitinbhatt46 profile image

"Day 55 of My Learning Journey: Setting Sail into Data Excellence! Today's Focus: Maths for Data Analysis (Probability - 1)

Nitin-bhatt46 - Apr 2

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

r report interactive

The following navigation utilizes arrow, enter, escape, and space bar key commands. Left and right arrows move through main tier links and expand / close menus in sub tiers. Up and Down arrows will open main tier menus and toggle through sub tier links. Enter and space open menus and escape closes them as well. Tab will move on to the next part of the site rather than go through menu items.

Due to system maintenance, users will be unable to log into airweb.org December 12–14, 2022. If you need assistance, please email [email protected].

  • Using HTML Widgets for R to Create Interactive Reports
  • by Inger Bergom

Institutional researchers are often tasked with synthesizing large amounts of data, perhaps by visualizing it in charts or summarizing it in tabular format. Allowing users to interact with these charts or tables by sorting or filtering, for instance, can reveal trends or highlight a particular subgroup. Many tools allow analysts to create interactive tables or charts. Tableau and PowerBI, for example, are popular in the institutional research community, but these can be expensive and require a server to host and share reports. The R environment is another option for creating interactive visualizations and may be particularly useful for institutional research offices that already use R for data analysis or data management tasks.

Users of R, in fact, have seen many developments in tools for creating interactive data visualizations. John Coene, the author of JavaScript for R (2021), writes, “The R programming language has been propelled into web browsers with the introduction of packages such as Shiny (Chang, Cheng, Allaire, et al., 2021) and R Markdown (Allaire et al., 2021) which have greatly improved how R users can communicate complex insights by building interactive web applications and interactive documents .” This article describes a free set of packages, or “HTML widgets,” to use within the R environment for producing interactive data reports.

What are HTML Widgets?

HTML widgets are R packages using JavaScript (JS) libraries that are not available natively to R. They enable users to create visualizations with interactive features, such as sorting, filtering, and tooltips. While R Shiny apps are powerful and can also produce interactive visualizations, they need to be hosted on a server in order to disseminate, which can add complexity when reports should not be made public. HTML widgets for R, on the other hand, can be used in R Markdown to render an HTML file that can then be shared and opened in a web browser. The underlying, disaggregated dataset is not shared, an important feature when working with sensitive data. Some knowledge of the R programming language is required when using HTML widgets and can be learned through various free online resources and tutorials. The widget features and customization options are not always as robust as paid applications such as Tableau or PowerBI, but HTML widgets for R are free and open source and can be useful tools in the institutional researcher’s analytic toolbox. It is also helpful to keep in mind that because R is open source, users can develop their own HTML widgets and packages to create new functionality that suits their needs.

HTML widgets can be used at the R console or within R Markdown, Quarto, or Shiny web applications. The examples below were created with R Markdown. An R Markdown document combines markdown (a markup language) with “chunks” of embedded R code. The document can be viewed and rendered, or “knitted,” through the RStudio IDE (Integrated Development Environment). It is worth noting that Quarto is the recently released successor to R Markdown and supports languages besides R, such as Python and ObservableJS. However, R Markdown is still available to use.

Examples of HTML Widgets

Although others are worth exploring, this section highlights a few of the HTML widget packages available: DT, ggplotly, crosstalk, leaflet, and flexdashboard. To view the interactive sample reports linked below, click on each link which takes you RPubs where the sample reports are published.

Interactivity is not only useful for graphs or charts but also can improve the user experience for data tables. The DT package provides an R interface to the JavaScript library DataTables and supports creating interactive tables. Tables can be sorted, searched, filtered, and customized in appearance and pagination specifications. The example linked to below is a table of information from the IPEDS 2020 Academic Libraries Survey Library and IPEDS 2020 Institutional Characteristics Survey.

Go to DT example

Many people who work with R for data analysis use the powerful ggplot2 package to create graphs and charts. ggplotly converts a ggplot2 object to a plotly object. plotly is a graphing library for making interactive, high-quality graphs. In the example below, a ggplot2 object showing a bar chart of university library book counts was passed through ggplotly to create a plotly chart. plotly interactive control buttons are displayed in the top right, and users can also click on the legend categories to filter for those groups.

A bar chart showing IPEDS 202 data on the U.S. Research Universities with the Most Library Books. Harvard University and University of California-Los Angeles top the chart.

Go to ggplotly example

crosstalk and leaflet

Crosstalk is an add-on to HTML widgets that enables cross-widget interactions. This means, for instance, that filtering a table created with one widget would simultaneously filter a figure created using a different widget, if the table and figure were connected using crosstalk. The example below uses crosstalk to link a table created with DT and a map generated using leaflet, a package for creating interactive maps. Selecting “Control” type (private or public) filters both the map and table. Clicking on rows of the table will filter the locations displayed on the map.

Screenshot of crosstalk example showing a map with placement of US Research Libraries with the Most Books.

Go to crosstalk example

Flexdashboard

Flexdashboard enables the creation of a single data dashboard containing separate sections or tabs. Charts, tables, or text can be arranged on a page in columns, rows, and tabs or presented as a storyboard sequence. Several sample projects with source code are available here .

r report interactive

Go to flexdashboard example

Publishing and Sharing Reports

The visualization, table, or dashboard generated using HTML widgets can be rendered as an HTML file using R Markdown or Quarto. The HTML file can then be sent as an email attachment or uploaded to a shared drive, similar to sharing a Word or Excel file. The HTML file opens in a browser on the user’s local computer. Alternatively, reports can be published to a website or server, but in those cases permissions for non-public reports need to be managed through the server or website.

Many resources are available online for learning the packages described above, as well as R, R Markdown, and Quarto. Here are just a few:

  • HTML Widgets Gallery: http://gallery.htmlwidgets.org/
  • DT: https://rstudio.github.io/DT/
  • leaflet: https://rstudio.github.io/leaflet/
  • crosstalk: https://rstudio.github.io/crosstalk/
  • flexdashboard: https://pkgs.rstudio.com/flexdashboard/articles/examples.html
  • R Markdown: https://R Markdown.rstudio.com/
  • R Markdown Cookbook: https://bookdown.org/yihui/R Markdown-cookbook/
  • Quarto: https://quarto.org/

community

Introduction to interactive documents

Garrett Grolemund

July 9, 2014

Interactive documents are a new way to build Shiny apps. An interactive document is an R Markdown file that contains Shiny widgets and outputs. You write the report in markdown , and then launch it as an app with the click of a button.

The previous article, Introduction to R Markdown , described how to write R Markdown files. R Markdown files are useful because

  • They are quick and easy to write.
  • You can embed executable R code into your file, which saves manual labor and creates a reproducible report.
  • You can convert R Markdown files into HTML, PDF, and Word documents with the click of a button.
  • You can convert R Markdown files into ioslides and beamer slideshows with the click of a button.

In fact, R Markdown files are the ultimate R reporting tool.

This article will show you one more thing that R Markdown files can do: you can embed Shiny components in an R Markdown file to create an interactive report or slideshow.

Your report will be a complete Shiny app. In fact, R Markdown provides the easiest way to build light-weight Shiny apps. I will refer to apps that combine Shiny with R Markdown as interactive documents .

Interactive documents

You can make an R Markdown document interactive in two steps:

  • add runtime: shiny to the document’s YAML header.
  • add Shiny widgets and Shiny render functions to the file’s R code chunks

The rmarkdown package will compile your document into a reactive Shiny app. The document will look just as it would otherwise, but it will include reactive components.

runtime: shiny

Notify rmarkdown that your file contains Shiny components by adding runtime: shiny to the file’s YAML header. RStudio will change its “Knit” icon to a “Run Document” icon when you save this change.

YAML header that says runtime: shiny, output: html_document

“Run Document” is a cue that rmarkdown will no longer compile your document into a static file. Instead it will “run” the document as a live Shiny app.

Since the document is a Shiny app, you must render it into an HTML format. Do this by selecting either html_document or ioslides_presentation for your final output.

To add a widget to your document, call a Shiny widget function in an R code chunk. R Markdown will add the widget to the code chunk’s output.

For example, the file below creates an HTML document with two widgets.

The document looks like this when rendered:

Rendered output

To add reactive output to your document, call one of the render* functions below in an R code chunk.

R Markdown will include the rendered output in the result of the code chunk.

This output will behave like rendered output in a standard Shiny app. The output will automatically update whenever you change a widget value or a reactive expression that it depends on.

The file below uses renderPlot to insert a histogram that reacts to the two widgets.

The document creates the app below when you click “Run Document.”

The structure of an interactive document

When you run an interactive document, rmarkdown extracts the code in your code chunks and places them into a pseudo server.R file. R Markdown uses the html output of the markdown file as an index.html file to place the reactive elements into.

Diagram showing code from a .Rmd file for a Shiny app go to server.R and the .Rmd file goes to a HTML file.

As a result, outputs in one code chunk can use widgets and reactive expressions that occur in other code chunks.

Since the R Markdown document provides a layout for the app, you do not need to write a ui.R file.

Sharing interactive documents

Interactive documents are a type of Shiny app, which means that you can share them in the same way that you share other Shiny apps. You can

  • Email a .Rmd file to a colleague. He or she can run the file locally by opening the file and clicking “Run Document”
  • Host the document with Shiny Server or Posit Connect
  • Host the document at ShinyApps.io

Note: If you are familiar with R Markdown, you might expect RStudio to save an HTML version of an interactive document in your working directory. However, this only works with static HTML documents. Each interactive document must be served by a computer that manages the document. As a result, interactive documents cannot be shared as a standalone HTML file.

Interactive documents provide a new and easy way to make Shiny apps.

Interactive documents will not replace standard Shiny apps since they cannot provide the design options that come with a ui.R or index.html file. However, interactive documents do create some easy wins:

The R Markdown workflow makes it easy to build light-weight apps. You do not need to worry about laying out your app or building an HTML user interface for the app.

You can use R Markdown to create interactive slideshows, something that is difficult to do with Shiny alone. To create a slideshow, change output: html_document to output: ioslides_presentation in the YAML front matter of your .Rmd file. R Markdown will divide your document into slides when you click “Run Document.” A new slide will begin whenever a header or horizontal rule ( *** ) appears.

Interactive documents enhance the existing R Markdown workflow. R Markdown makes it easy to write literate programs and reproducible reports. You can make these reports even more effective by adding Shiny to the mix.

To learn more about R Markdown and interactive documents, please visit rmarkdown.rstudio.com .

MarketSplash

How To Create Interactive Visualizations In R: A Step-By-Step Approach

Learn to create interactive visualizations in R, a skill crucial for modern developers. This article guides you through selecting the right packages, setting up your environment, and crafting dynamic, user-responsive charts and graphs.

💡 KEY INSIGHTS

  • Transitioning basic plots to interactive ones is straightforward in R; beginning with a ggplot2 scatter or bar chart and then converting it to an interactive Plotly chart enriches the user experience with added interactivity and dynamism​​.
  • Customization and enhancement of interactivity in plots can be achieved through various means, such as adding tooltips for additional information or employing the gganimate package for creating engaging animations, illustrating changes over time or categories​​​​.
  • R's capabilities extend to sophisticated interactive reports by using HTML widgets within R Markdown, enabling features like sorting, filtering, and tooltips without sharing the underlying sensitive data, which is crucial for institutional research and data management​​.
  • Shiny's integration for advanced interactive features in R, like animations, event handling, and linking multiple plots, allows for the creation of highly dynamic and responsive visualizations, encouraging deeper exploration and understanding of data​​.

Creating interactive visualizations in R can significantly enhance data presentation and analysis, offering a more engaging experience for users. This article guides programmers and developers through the essential steps and tools needed to build these interactive elements. With practical examples and straightforward explanations, you'll learn how to bring your data to life in R.

r report interactive

Setting Up R for Visualization

Choosing visualization packages, creating basic interactive charts, advanced interactive features, frequently asked questions, setting up r, installing necessary packages, basic visualization example, customizing your plot.

To start creating visualizations in R, the first step is installing R and its companion software, RStudio. RStudio enhances the R experience with a user-friendly interface and additional features. Download and install both from their respective websites.

Once installed, open RStudio and set up your workspace. A clean, organized workspace is crucial for efficient coding. Use the setwd() function to define your working directory.

R's power in visualization largely comes from its packages. The ggplot2 package is essential for creating high-quality graphics. Install it using the install.packages() function.

With ggplot2 installed, you can start creating basic plots. Here's a simple example to plot a scatter plot.

Customization is key to making your visualizations stand out. You can add titles, change colors, and modify axis labels in ggplot2 .

By following these steps, you set a strong foundation for creating interactive and engaging visualizations in R. Remember, the key to mastering R visualizations lies in experimentation and practice.

Choosing Packages

Interactive graphics with plotly, creating an interactive plot, leveraging shiny for web applications.

In R, the choice of visualization packages can greatly influence the style and interactivity of your graphics. ggplot2 is a popular choice for its elegant and versatile plotting capabilities.

To use ggplot2, first install and load it in your R environment:

For interactive visualizations, plotly is a go-to package. It allows users to interact with the plots, such as zooming and hovering for details.

Install and load plotly as follows:

Once plotly is loaded, you can convert a ggplot object to an interactive plotly object. Here's a simple example:

For more advanced interactivity, especially in web applications, Shiny is an excellent package. It allows for the creation of interactive web apps directly from R.

To get started with Shiny:

Each of these packages offers unique features and capabilities for visualization in R. Experimenting with them will help you understand their strengths and how they can be combined to create compelling and interactive visual presentations.

Creating Charts

Simple interactive scatter plot, adding tooltips, interactive bar chart.

Creating basic interactive charts in R is a straightforward process, especially with the plotly package. This package transforms static ggplot2 charts into interactive visualizations.

First, ensure you have plotly installed and loaded:

A scatter plot is a great starting point for interactive charts. Begin with a basic ggplot2 scatter plot and then convert it to an interactive plotly chart.

Tooltips enhance interactivity by displaying additional information when hovering over data points. Plotly automatically adds tooltips, but you can customize them.

Bar charts are another fundamental type of visualization. They can also be made interactive with plotly.

By starting with these basic types of interactive charts, you can begin to explore the vast potential of interactive data visualization in R. Experiment with different plot types and customization options to enhance the user experience.

Animations In Plotly

Event handling with shiny, linking multiple plots.

Expanding beyond basic charts, R offers Advanced Interactive Features for more dynamic and engaging visualizations. These features include animations, event handling, and linking plots.

Animations add a dynamic element to your charts, illustrating changes in data over time or categories. Plotly's animation capabilities are robust and easy to implement.

Shiny allows for sophisticated event handling in your interactive visualizations. You can create reactive visualizations that update based on user input.

Linking multiple plots creates a more comprehensive view of your data. Users can interact with one plot to see corresponding changes in another.

These advanced features in R's visualization tools allow for creating highly interactive and responsive visualizations. They enable users to explore data in more depth and provide a richer understanding of the underlying information.

How do I handle large datasets in interactive visualizations?

For large datasets, consider using data summarization techniques or interactive features that allow users to focus on subsets of the data. Plotly and Shiny both handle large datasets effectively, but optimizing your data and plot code is crucial for performance.

Are there any resources for learning advanced visualization techniques in R?

Yes, there are numerous resources available online, including R documentation, dedicated blogs, online courses, and forums like Stack Overflow. The R community is very active, and many experienced users share their knowledge and code.

How can I customize the appearance of my interactive plots?

Both ggplot2 and plotly offer extensive customization options. You can change colors, shapes, add themes, modify text, and much more. The documentation for these packages provides detailed guidelines on customization.

Is it possible to create 3D visualizations in R?

Yes, R supports 3D visualizations, and plotly is particularly adept at creating them. You can use plotly to create interactive 3D scatter plots, surface plots, and more.

Let’s test your knowledge!

Which package is commonly used for creating interactive web applications in R?

Continue learning with these 'programming' guides.

  • How To Debug In R: Effective Strategies For Developers
  • How To Use R For Simulation: Effective Strategies And Techniques
  • How To Install R Packages: Steps For Efficient Integration
  • How To Import Data In R: Essential Steps For Efficient Data Analysis
  • How To Clean Data In R: Essential Techniques For Effective Data Management

Subscribe to our newsletter

Subscribe to be notified of new content on marketsplash..

r report interactive

Powerful pre-built Wrkflow automations to get you started quickly.

r report interactive

Automation Blog

Become a partner, r markdown automated reports (and easier ways to automate with wrk).

Beck Pura | May 24, 2023, 7:11 p.m. | 5 min read

r report interactive

What is R Markdown?

R Markdown is an authoring framework for data science. It allows you to create documents that serve as a comprehensive record of your work. These documents can contain your code, the outputs produced by that code (like figures, tables, etc.), and narrative text that provides context for the code and its outputs.

Importance and use of R Markdown

R Markdown is invaluable in promoting reproducible research, a cornerstone of robust data science. It enables you to reproduce the exact computation and output at any time quickly. Furthermore, You can render R Markdown documents in numerous formats, including HTML, PDF, Word, slides, notebooks, dashboards, and more.

R Markdown vs. Traditional Markdown

Traditional Markdown is a lightweight markup language with plain-text formatting syntax. Its primary purpose is to simplify the writing of HTML. In contrast, R Markdown extends the traditional Markdown syntax to include chunks of executable R code within the document, making it a dynamic document generation tool.

Components of an R Markdown file

An R Markdown file has three main components. The first is a YAML header that includes metadata and options for rendering the document. The second component is the narrative text written in Markdown format. Finally, there are chunks of executable R code.

Getting Started with R Markdown

Required software and packages.

To start with R Markdown, you must have R and RStudio installed on your machine. Additionally, you need to install the markdown package using the command install.packages("markdown") in R.

Creating Your First R Markdown Document

To create an R Markdown document in RStudio, go to File > New File > R Markdown..., then choose your desired document type and output format.

Basic Syntax for Formatting Text in R Markdown

R Markdown uses the Markdown language for text formatting. For example, you can make text italic by wrapping it with * or _and bold with ** or __. You can create headers by using #, with the level of heading determined by the number of # used.

Including Code Chunks in R Markdown

You must enclose the code within triple backticks and {r} to include R code chunks in your document. For example,

r markdown code

print("Hello, world!")

will print "Hello, world!" when the document is knit.

Markdown Advanced Usage

Parameterizing reports.

R Markdown supports parameterized reports, which allow you to run the same report with different input parameters. Having parameters is useful for creating similar reports for other datasets or different subsets of a dataset.

Incorporating R Scripts

R scripts can be sourced in an R Markdown document using the source() function. R scripts allow you to separate code into multiple files for better organization and reuse.

Output Formatting Options

R Markdown supports various output formats, including HTML, PDF, Word, slides, and more. You can control the output format and its options using the YAML header.

Integration with Knitr and Pandoc

R Markdown integrates with the Knitr and Pandoc packages to convert your document into the final output format. The knit package executes the code chunks and embeds the output in the document, while Pandoc converts the Markdown text into the desired output format.

Using Citations in R Markdown

You can easily include citations in your R Markdown documents. To do this, you specify a bibliography file in the YAML header, then use the @ syntax to cite references in the text.

Customizing R Markdown Reports with YAML Header

The YAML header in an R Markdown document provides a range of customization options, including document metadata (title, author, date), output format and opportunities, and more.

R Markdown Automated Reports

What is r markdown automation.

R Markdown automated reports involves is the process of automatically generating reports on a scheduled basis. This type of automation uses a scheduler like cron on Unix-based systems or Task Scheduler on Windows.

Benefits and Applications of R Markdown Automated Reporting

Automated reporting with R Markdown has benefits. It allows for up-to-date reports to be generated regularly without manual intervention. Automating your reports is particularly useful for tracking metrics over time, such as website analytics or business performance metrics.

Common Tools and Techniques for Automation

There are several tools and techniques for automating R Markdown reports. These include the cronR and task scheduler packages for scheduling report generation and the mail and blastula packages for email delivery of reports.

Building Automated Reports with R Markdown

Preparing your r markdown document for automation.

To prepare your R Markdown document for automation, you first need to ensure that it can be rendered without manual intervention. This includes removing any interactive elements and ensuring that all data sources can be accessed automatically.

Scheduling and Running R Markdown Automated Reports

Once your document is ready, you can schedule it to be rendered regularly using a tool like cron or Task Scheduler. The specific steps for doing this will depend on your operating system.

Error Handling and Debugging in Automated Reports

Error handling is an essential part of automated reporting. You should include measures to handle potential errors in your code and log any errors that occur during the rendering of the report. You can use the try-catch () function in R for error handling.

Delivering Automated Reports (Email, Dashboards, Webpages)

After your report is generated, you can deliver it in various ways. This could be as simple as writing it to a file on your system, or you could email it to stakeholders, publish it as a webpage, or integrate it into a dashboard.

Step-by-Step Guide to Building an Automated R Markdown Report

Step 1: Install Necessary Packages

The first step is to install the necessary packages. You'll need the markdown package for creating the report, and depending on your needs, you might also need packages for data access, visualization, scheduling, email delivery, and more.

Step 2: Create and Structure Your R Markdown Document

Next, create your R Markdown document. This will include writing the narrative text, adding code chunks, and specifying the output format and options in the YAML header.

Step 3: Add Dynamic Elements to Your R Markdown Document

To make your report dynamic, you can include elements that change based on the data or the time of rendering. This could consist of parameterized code chunks, dynamic text, or plots that show the most recent data.

Step 4: Set Up the YAML Header for Automation

The YAML header in your R Markdown document can include options that are specifically for automation. For example, you might include an eval option to specify that specific code chunks should only be run during automation.

Step 5: Test Your R Markdown Document

Before automating your document, make sure to thoroughly test it. This includes checking that it renders correctly, that all dynamic elements work as expected, and that all data sources can be accessed automatically.

Step 6: Schedule Your Automated Report

Once your document is ready and tested, you can schedule it to be rendered automatically. This can be done using a scheduler like cron or Task Scheduler.

Step 7: Implement Error Handling Measures

Ensure that your R Markdown document includes measures to handle and log errors that might occur during rendering. This can help you identify and fix issues that might prevent your automated report from being generated correctly.

Step 8: Decide on a Delivery Method for Your Automated Report

Decide how to deliver your automated reports. The delivery method could be as a file on your system, an email to stakeholders, a webpage, or part of a dashboard.

Step 9: Monitor Your Automated Report and Make Adjustments as Needed

While your report is being generated and delivered automatically, continue to monitor it to ensure it works correctly. Make adjustments as needed, such as tweaking the code to handle changes in the data or changing the delivery method to better meet the needs of your stakeholders.

R Markdown Automated Reports vs Workflow Automation Tools Like Wrk

While R Markdown and workflow automation platforms like Wrk are all powerful tools for reporting and automation, they differ significantly in their functions and use cases. Here's a comparison:

  • Functionality and Purpose:
  • R Markdown Automated Reports: R Markdown is specifically designed for creating dynamic, reproducible documents that combine code (primarily R, but also Python and SQL), results, and narrative text. Automated R Markdown reports enable you to schedule these dynamic documents to be generated and updated regularly, making them excellent for monitoring metrics over time or creating up-to-date reports without manual intervention.
  • Workflow Automation Tools Like Wrk: These tools are designed to automate entire business processes and workflows, which can involve a wide range of tasks, not just report generation. Wrk has a range of existing Wrk actions and integrations making it an excellent project collaboration tool. Team members to manage projects, deadlines, and other Wrkflows while also automating repetitive tasks to improve efficiency
  • R Markdown Automated Reports: R Markdown is typically used by data scientists, statisticians, and researchers who need to create reproducible research and reports that blend code execution with narrative text and visualizations.
  • Wrk: Wrk caters to a broader audience, including project managers, marketers, sales teams, customer support, and other non-technical roles that benefit from automating repetitive tasks and integrating various software applications.
  • Language and Environment:
  • R Markdown Automated Reports: R Markdown is used within the R or RStudio environment. Users must have familiarity with R and the Markdown language to use it effectively.
  • Wrk: Wrk provides a graphical user interface (GUI) and does not require knowledge of a specific programming language. However, it may require understanding of different applications to set up effective Wrkflows (but our Automation Experts can also help with that!)
  • Flexibility and Control:
  • R Markdown Automated Reports: R Markdown offers a high degree of flexibility and control over the contents and format of reports, with options to include sophisticated analyses and custom visualizations. However, its automation capabilities are relatively basic.
  • Wrk: Wrk offers powerful automation capabilities, with options to control the flow of data between different applications and perform complex sequences of tasks. What's more is Wrk has automated reporting capabilities that require far less effort than R Markdown.

If your goal is to automate complex workflows that involve multiple different applications and do not primarily revolve around creating Wrk might be the right tool for you.

r markdown reports

Pay per-use Automation

  • Find a lead's phone number or email address: $0.25 per contact
  • Extract every line item from an invoice or receipt: $1.00 per receipt
  • Generate ChatGPT powered presentations: FREE

r report interactive

Automating Customer Feedback in Insurance

r report interactive

Digital Onboarding Automation in Insurance

r report interactive

Dynamic Pricing in Insurance Through Automation

R-bloggers

R news and tutorials contributed by hundreds of R bloggers

Data visualization reloaded: equipping your reports with the ultimate r package arsenal.

Posted on March 28, 2024 by Numbers around us in R bloggers | 0 Comments

r report interactive

In the vast and ever-expanding universe of data, the ability to not just see but truly understand the stories hidden within numbers becomes paramount. This journey of comprehension isn’t unlike the iconic moment from The Matrix , where Neo, standing amidst the endless possibilities of the digital realm, declares his need for “Guns, lots of guns.” In the context of our exploration, these “guns” are not weapons of destruction but powerful tools of creation and insight — data visualization packages for R, each with its unique capabilities to transform raw data into compelling narratives.

Our quest is navigated through the versatile landscapes of Quarto and R Markdown (Rmd), platforms that serve as the backbone for our reports. Whether you’re drafting an interactive web document, a static PDF, or a neatly formatted Word file, these tools are the canvases upon which our data stories will unfold. But a canvas alone does not make art — it’s the brushes, colors, and techniques that bring a scene to life. Similarly, our chosen R packages — each a brushstroke of genius — allow us to paint intricate pictures with our data.

This article will serve as your guide through this arsenal of visualization packages. From the foundational ggplot2 to the interactive plotly, the geospatial leaflet, and the detailed gt for tabular artistry, we'll cover a spectrum of tools that cater to every analyst's, researcher's, and data storyteller's needs. We'll delve into how each package can be utilized within Quarto and R Markdown to create reports that not only convey information but also engage and enlighten your audience.

As we embark on this journey together, remember that the power of these tools lies not just in their individual capabilities but in how they can be combined to tell a cohesive, compelling story. By the end of this exploration, you’ll be equipped with a diverse and potent arsenal, ready to tackle any data visualization challenge that comes your way.

Let the journey begin.

The Foundation with ggplot2

At the heart of our data visualization arsenal lies ggplot2, a package that has revolutionized the way we think about and create graphics in R. Inspired by Leland Wilkinson's Grammar of Graphics, ggplot2 allows users to assemble plots layer by layer, making the creation of complex visualizations both intuitive and accessible.

ggplot2 shines in its ability to break down and understand data visualization as a series of logical steps: data selection, aesthetic mapping, geometric objects, and statistical transformations. This structured approach enables users to craft nearly any type of graphic, from simple scatter plots to intricate layered visualizations. The package's extensive customization options—through scales, themes, and coordinates—further empower users to tailor their visuals to the precise narrative they wish to convey.

For reports in Quarto or R Markdown, ggplot2 acts as the foundational tool for data visualization. Its versatility is unmatched, offering crisp, publication-quality graphics for static outputs (PDF, DOCX) and adaptable visuals for dynamic HTML documents. Whether you're creating a formal report, a comprehensive academic paper, or an engaging web article, ggplot2 provides the necessary tools to visually articulate your data's story.

To illustrate the power of ggplot2, let's create a simple yet elegant scatter plot:

r report interactive

This code snippet highlights ggplot2's simplicity and elegance, creating a plot that is both visually appealing and informative. As we proceed to explore more specialized packages, ggplot2 remains our trusted foundation, enabling us to build upon it and enhance our reports with diverse visual narratives.

Enhancing Interactivity with plotly

In the dynamic world of web-based reporting, plotly stands out as a beacon of interactivity. It builds upon the static beauty of ggplot2 plots by adding a layer of engagement through interactive elements. Users can hover over data points, zoom in on areas of interest, and filter through datasets directly within their plots, transforming a static visualization into an interactive exploration.

plotly offers a wide range of interactive chart types, including line charts, bar charts, scatter plots, and more, all with the added benefit of user interaction. It's particularly adept at handling large datasets, making it possible to explore and interpret complex data in real-time. The package's ability to integrate with ggplot2 means that users can easily elevate their existing visualizations from static to dynamic with minimal effort.

For HTML reports created in Quarto or R Markdown, plotly enhances the reader's experience by making the data exploration an integral part of the narrative. This level of interactivity invites the audience to engage with the data on a deeper level, facilitating a more personalized exploration of the findings. It's especially useful in scenarios where understanding data nuances is crucial, such as in exploratory data analysis or when presenting results to a diverse audience.

Here’s how to transform a ggplot2 plot into an interactive plotly plot:

This code demonstrates the ease with which a static ggplot2 visualization can be converted into an interactive plotly graph. By incorporating plotly into your data storytelling toolkit, you unlock a world where data visualizations are not just seen but experienced.

Mapping Data with leaflet

Geospatial data visualization is a critical aspect of storytelling in many fields, from environmental science to urban planning. leaflet for R brings the power of interactive mapping to your reports, allowing you to create detailed, dynamic maps that can be embedded directly into HTML documents. Based on the Leaflet.js library, it is the premier tool for building interactive maps in the R ecosystem.

With leaflet, you can layer multiple data sources on a single map, customize map appearances, and add interactive features like pop-ups and markers. It supports various map types, including base maps from OpenStreetMap, Mapbox, and Google Maps. Whether you're tracking migration patterns, visualizing climate change data, or showcasing demographic trends, leaflet makes geospatial data accessible and engaging.

For Quarto or R Markdown reports destined for the web, leaflet maps offer a dynamic way to present geospatial data. Unlike static maps, leaflet enables readers to zoom in and out, explore different layers, and interact with the data points directly. This interactivity enhances the user's engagement and understanding, making leaflet an invaluable tool for reports that include location-based analysis or findings.

Creating an interactive map with leaflet is straightforward:

r report interactive

This example demonstrates how to create a basic interactive map showing specific locations. With leaflet, the complexity and depth of your geospatial visualizations are limited only by your imagination.

Interactive Tables with DT

In the realm of data presentation, tables are indispensable for displaying detailed information in a structured manner. DT (DataTables) is an R package that integrates the jQuery DataTables plugin, transforming static tables into interactive exploration tools. It enables users to search, sort, and paginate tables directly within HTML reports, enhancing the user's ability to engage with and understand the data.

DT offers a plethora of features to make tables more interactive and user-friendly. Highlights include automatic or custom column filtering, options for table styling, and the ability to include buttons for exporting the table to CSV, Excel, or PDF formats. These functionalities are particularly useful in reports that contain large datasets, allowing readers to navigate and focus on the data that interests them most.

For reports generated in Quarto or R Markdown with an HTML output, DT provides a superior way to present tabular data. It bridges the gap between static tables, which can be overwhelming and difficult to navigate, and the need for dynamic, accessible data presentation. Whether you're summarizing survey results, financial data, or scientific measurements, DT tables can significantly improve the readability and usability of your reports.

Here’s a simple example of how to create an interactive table with DT:

r report interactive

This code snippet demonstrates how to convert a subset of the mtcars dataset into an interactive table, complete with pagination and adjustable column widths. By integrating DT into your reporting toolkit, you can ensure that even the densest data tables become navigable and insightful components of your narrative.

The Grammar of Tables with gt

While DT focuses on interactivity for data tables, the gt package brings unparalleled levels of customization and styling to table creation in R. Standing for "Grammar of Tables," gt allows you to create highly detailed and beautifully formatted tables that communicate information clearly and effectively, akin to how ggplot2 revolutionizes plot creation.

gt enables you to craft tables that go beyond mere data presentation; it allows you to tell a story with your data. From adding footnotes, coloring cells based on values, to creating complex layouts with grouped headers and spanning labels, gt provides a comprehensive suite of tools for enhancing the aesthetic and functional aspects of tables in your reports.

In Quarto or R Markdown reports, regardless of the output format (HTML, PDF, or DOCX), gt tables can significantly elevate the visual standard and readability of your presentations. Especially in PDFs and printed documents, where interactive elements are not feasible, the detailed customization gt offers makes your tables not just data containers but key narrative elements of your report.

To demonstrate the capabilities of gt, let's create a simple yet styled table using a subset of the mtcars dataset:

r report interactive

This code snippet highlights how gt not only allows for the structuring and presentation of tabular data but also for the artistic expression within data reporting, making your tables both informative and visually appealing.

Bringing Plots to Life with ggiraph

In the quest to make reports more engaging, ggiraph emerges as a powerful ally, enabling the transformation of static ggplot2 graphics into interactive visual stories. ggiraph allows elements within ggplot2 plots, such as points, lines, and bars, to become interactive, supporting tooltips, hover actions, and even hyperlinks. This interactivity enriches the user experience, allowing for a deeper exploration and understanding of the underlying data.

The ggiraph package shines when you want to add a layer of engagement to your data visualizations. With it, viewers can hover over specific elements to see more details or click on parts of the graph to access external resources. This capability is invaluable for online reports, where reader engagement and interactivity are paramount.

For HTML-based reports created with Quarto or R Markdown, ggiraph enhances the storytelling potential by making data visualizations a two-way interaction channel. This feature is especially useful for exploratory data analysis, educational materials, or any report aiming to provide an immersive data exploration experience. While ggiraph excels in web environments, the static versions of these enriched plots still retain their aesthetic and informational value in PDF or DOCX outputs.

Here’s a basic example of how to create an interactive plot with ggiraph, making use of a simple ggplot2 bar chart:

r report interactive

This example assumes a scenario where clicking on a point in the scatter plot (simplified here as clicking on a category) would dynamically update the histogram to show the distribution of values for that category.

Seamless Plot Compositions with patchwork

While ggiraph brings individual plots to life with interactivity, patchwork is the tool for harmoniously combining multiple ggplot2 plots into a cohesive composition. patchwork simplifies the process of arranging multiple plots, allowing for complex layouts that maintain a unified aesthetic. It's akin to assembling a visual symphony from individual notes, where each plot plays its part in the overarching data narrative.

patchwork excels in its flexibility and ease of use, offering a syntax that is both intuitive and powerful. It allows for the vertical, horizontal, and nested arrangement of plots, and gives you control over spacing, alignment, and even shared legends. This capability is invaluable when you need to compare different aspects of your data side by side or tell a multi-faceted story through a series of visualizations.

In both Quarto and R Markdown reports, regardless of the output format, patchwork enables you to create visually appealing and informative plot arrangements. For static reports (PDF, DOCX), these compositions can help convey complex information in a digestible format. For HTML reports, while patchwork does not add interactivity to the plots themselves, the strategic arrangement of visual elements can guide the reader’s exploration of the data.

To demonstrate the power of patchwork, let's create a composition of two simple ggplot2 plots:

r report interactive

This example illustrates how patchwork seamlessly combines two distinct ggplot2 plots into a single, coherent visual statement. By arranging plots in a thoughtfully designed layout, you can enhance the storytelling impact of your data visualizations in reports.

Mastering Your Data Visualization Arsenal

Our journey through the landscape of R packages for enhancing reports in Quarto and R Markdown mirrors the pivotal scene from The Matrix , where an array of tools is summoned with a clear mission in mind. In our narrative, these tools — ggplot2, plotly, leaflet, DT, gt, ggiraph, and patchwork—form a robust arsenal, each offering unique capabilities to make our data reports not just informative, but compelling and engaging.

  • ggplot2 laid the foundation, offering a versatile platform for creating a wide range of plots with deep customization options, ensuring that every chart precisely conveys its intended message.
  • plotly and ggiraph introduced interactivity, transforming static images into dynamic conversations, inviting readers to explore and interact with the data on their terms.
  • leaflet allowed us to map our narratives, providing geographical context and making location data more accessible and understandable.
  • DT and gt revolutionized how we present tabular data, turning dense tables into clear, engaging visual elements of our reports.
  • patchwork taught us the art of composition, enabling us to weave individual plots into coherent visual stories that guide the reader through our analyses seamlessly.

Each of these packages can be seen as a different type of “firearm” in our data visualization arsenal, equipped to tackle specific challenges and objectives in the realm of digital reporting. Whether we’re aiming for clarity, engagement, interactivity, or all of the above, our toolkit is now fully stocked to bring any data story to life.

As we conclude this exploration, remember that the true power of these tools lies not just in their individual capabilities but in how they can be combined to tell a cohesive, compelling story. Just as Neo chose his arsenal for the mission ahead, you now have the knowledge to select the right tools for your data visualization needs, ensuring your reports are not only seen but remembered.

The landscape of data storytelling is vast and ever-changing, but with this arsenal at your disposal, you’re well-equipped to make your mark. So, take these tools, explore their potential, and start crafting data stories that resonate, inform, and inspire.

r report interactive

Data Visualization Reloaded: Equipping Your Reports with the Ultimate R Package Arsenal was originally published in Numbers around us on Medium, where people are continuing the conversation by highlighting and responding to this story.

Copyright © 2024 | MH Corporate basic by MH Themes

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

Big Book of R

28.1 getting used to r, rstudio, and r markdown.

by Chester Ismay

This resource is designed to provide new users to R, RStudio, and R Markdown with the introductory steps needed to begin their own reproducible research. A review of many of the common R errors encountered (and what they mean in layman’s terms) will also provided be provided.

Link: https://bookdown.org/chesterismay/rbasics/

28.2 Introduction to R Markdown

by Michael Clark

The goal is for you to be able to get quickly started with your own document, and understand the possibilities available to you. You will get a feel for the basic mechanics at play, as well as have ideas on how to customize the result to your own tastes.

Link: https://m-clark.github.io/Introduction-to-Rmarkdown/

by Yihui Xie

Dynamic documents with R and knitr!

The knitr package was designed to be a transparent engine for dynamic report generation with R, solve some long-standing problems in Sweave, and combine features in other add-on packages into one package.

Link: https://yihui.org/knitr/

28.4 Pimp my RMD a few tips for R Markdown

by Yan Holtz

R markdown creates interactive reports from R code. This post provides a few tips I use on a daily basis to improve the appearance of output documents.

Link: https://holtzy.github.io/Pimp-my-rmd/

28.5 R bookdownplus Textbook

by Peng Zhao

‘bookdownplus’ is an extension of ‘bookdown’. It is a collection of multiple templates, which I have been collecting since years ago on the basis of LaTeX, and have been tailoring them so that I can work happily under the umbrella of ‘bookdown’. ‘bookdownplus’ helps you (and me) write varied types of books and documents. This book you are reading at the moment was exactly produced by ‘bookdownplus’.

Link: https://bookdown.org/baydap/bookdownplus/

28.6 R Markdown Cookbook

by Yihui Xie , Christophe Dervieux , Emily Riederer

This book showcases short, practical examples of lesser-known tips and tricks to helps users get the most out of these tools. After reading this book, you will understand how R Markdown documents are transformed from plain text and how you may customize nearly every step of this processing. For example, you will learn how to dynamically create content from R code, reference code in other documents or chunks, control the formatting with customer templates, fine-tune how your code is processed, and incorporate multiple languages into your analysis.

Link: https://bookdown.org/yihui/rmarkdown-cookbook/

28.7 R Markdown The Definitive Guide

by Yihui Xie , J. J. Allaire , Garrett Grolemund

The first official book authored by the core R Markdown developers that provides a comprehensive and accurate reference to the R Markdown ecosystem. With R Markdown, you can easily create reproducible data analysis reports, presentations, dashboards, interactive applications, books, dissertations, websites, and journal articles, while enjoying the simplicity of Markdown and the great power of R and other languages.

Link: https://bookdown.org/yihui/rmarkdown/

28.8 Report Writing for Data Science in R

by [Roger D. Peng]]( https://twitter.com/rdpeng )

This book teaches the fundamental concepts and tools behind reporting modern data analyses in a reproducible manner. As data analyses become increasingly complex, the need for clear and reproducible report writing is greater than ever.

Paid: Free or pay what you want $10

Link: https://leanpub.com/reportwriting

28.9 Reproducible Research with R and RStudio

by Christopher Gandrud

This book present all the Tools for Gathering and Analyzing Data and Presenting Results Reproducible Research with R and RStudio through practical examples.

The book can be reproduced by using the R package bookdown. You can buy a copy at:

https://www.routledge.com/Reproducible-Research-with-R-and-RStudio/Gandrud/p/book/9780367143985

Link: https://github.com/christophergandrud/Rep-Res-Book > Also, you can buy the copy.

28.10 RMarkdown for Scientists

by Nicholas Tierney

This is a book on rmarkdown, aimed for scientists. It was initially developed as a 3 hour workshop, but is now developed into a resource that will grow and change over time as a living book.

Link: https://rmd4sci.njtierney.com/

Buy Me a Coffee at ko-fi.com

For updates, sign up to my newsletter

Introduction to R Markdown

Garrett grolemund, july 16, 2014.

Interactive documents are a new way to build Shiny apps. An interactive document is an R Markdown file that contains Shiny widgets and outputs. You write the report in markdown , and then launch it as an app with the click of a button.

This article will show you how to write an R Markdown report.

The companion article, Introduction to interactive documents , will show you how to turn an R Markdown report into an interactive document with Shiny components.

R Markdown is a file format for making dynamic documents with R. An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of embedded R code, like the document below.

R Markdown files are designed to be used with the rmarkdown package. rmarkdown comes installed with the RStudio IDE, but you can acquire your own copy of rmarkdown from CRAN with the command

R Markdown files are the source code for rich, reproducible documents. You can transform an R Markdown file in two ways.

knit - You can knit the file. The rmarkdown package will call the knitr package. knitr will run each chunk of R code in the document and append the results of the code to the document next to the code chunk. This workflow saves time and facilitates reproducible reports.

Consider how authors typically include graphs (or tables, or numbers) in a report. The author makes the graph, saves it as a file, and then copy and pastes it into the final report. This process relies on manual labor. If the data changes, the author must repeat the entire process to update the graph.

In the R Markdown paradigm, each report contains the code it needs to make its own graphs, tables, numbers, etc. The author can automatically update the report by re-knitting.

convert - You can convert the file. The rmarkdown package will use the pandoc program to transform the file into a new format. For example, you can convert your .Rmd file into an HTML, PDF, or Microsoft Word file. You can even turn the file into an HTML5 or PDF slideshow. rmarkdown will preserve the text, code results, and formatting contained in your original .Rmd file.

Conversion lets you do your original work in markdown, which is very easy to use. You can include R code to knit, and you can share your document in a variety of formats.

In practice, authors almost always knit and convert their documents at the same time. In this article, I will use the term render to refer to the two step process of knitting and converting an R Markdown file.

You can manually render an R Markdown file with rmarkdown::render() . This is what the above document looks like when rendered as a HTML file.

r report interactive

In practice, you do not need to call rmarkdown::render() . You can use a button in the RStudio IDE to render your reprt. R Markdown is heavily integrated into the RStudio IDE .

Getting started

To create an R Markdown report, open a plain text file and save it with the extension .Rmd . You can open a plain text file in your scripts editor by clicking File > New File > Text File in the RStudio toolbar.

r report interactive

Be sure to save the file with the extension .Rmd . The RStudio IDE enables several helpful buttons when you save the file with the .Rmd extension. You can save your file by clicking File > Save in the RStudio toolbar.

r report interactive

R Markdown reports rely on three frameworks

  • markdown for formatted text

knitr for embedded R code

Yaml for render parameters.

The sections below describe each framework.

Markdown for formatted text

.Rmd files are meant to contain text written in markdown . Markdown is a set of conventions for formatting plain text. You can use markdown to indicate

  • bold and italic text
  • headers (e.g., section titles)
  • and much more

The conventions of markdown are very unobtrusive, which make Markdown files easy to read. The file below uses several of the most useful markdown conventions.

The file demonstrates how to use markdown to indicate:

headers - Place one or more hashtags at the start of a line that will be a header (or sub-header). For example, # Say Hello to markdown . A single hashtag creates a first level header. Two hashtags, ## , creates a second level header, and so on.

italicized and bold text - Surround italicized text with asterisks, like this *without realizing it* . Surround bold text with two asterisks, like this **easy to use** .

lists - Group lines into bullet points that begin with asterisks. Leave a blank line before the first bullet, like this

hyperlinks - Surround links with brackets, and then provide the link target in parentheses, like this [Github](www.github.com) .

You can learn about more of markdown’s conventions in the Markdown Quick Reference guide, which comes with the RStudio IDE.

To access the guide, open a .md or .Rmd file in RStudio. Then click the question mark that appears at the top of the scripts pane. Next, select “Markdown Quick Reference”. RStudio will open the Markdown Quick Reference guide in the Help pane.

r report interactive

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want.

r report interactive

When you click the button, rmarkdown will duplicate your text in the new file format. rmarkdown will use the formatting instructions that you provided with markdown syntax.

Once the file is rendered, RStudio will show you a preview of the new output and save the output file in your working directory.

Here is how the markdown script above would look in each output format.

r report interactive

Note: RStudio does not build PDF and Word documents from scratch. You will need to have a distribution of Latex installed on your computer to make PDFs and Microsoft Word (or a similar program) installed to make Word files.

The knitr package extends the basic markdown syntax to include chunks of executable R code.

When you render the report, knitr will run the code and add the results to the output file. You can have the output display just the code, just the results, or both.

To embed a chunk of R code into your report, surround the code with two lines that each contain three backticks. After the first set of backticks, include {r} , which alerts knitr that you have included a chunk of R code. The result will look like this

When you render your document, knitr will run the code and append the results to the code chunk. knitr will provide formatting and syntax highlighting to both the code and its results (where appropriate).

As a result, the markdown snippet above will look like this when rendered (to HTML).

r report interactive

To omit the results from your final report (and not run the code) add the argument eval = FALSE inside the brackets and after r . This will place a copy of your code into the report.

r report interactive

To omit the code from the final report (while including the results) add the argument echo = FALSE . This will place a copy of the results into your report.

r report interactive

echo = FALSE is very handy for adding plots to a report, since you usually do not want to see the code that generates the plot.

r report interactive

echo and eval are not the only arguments that you can use to customize code chunks. You can learn more about formatting the output of code chunks at the rmarkdown and knitr websites.

Inline code

To embed R code in a line of text, surround the code with a pair of backticks and the letter r , like this.

knitr will replace the inline code with its result in your final document (inline code is always replaced by its result). The result will appear as if it were part of the original text. For example, the snippet above will appear like this:

r report interactive

You can use a YAML header to control how rmarkdown renders your .Rmd file. A YAML header is a section of key: value pairs surrounded by --- marks, like below

The output: value determines what type of output to convert the file into when you call rmarkdown::render() . Note: you do not need to specify output: if you render your file with the RStudio IDE knit button.

output: recognizes the following values:

  • html_document , which will create HTML output (default)
  • pdf_document , which will create PDF output
  • word_document , which will create Word output

If you use the RStudio IDE knit button to render your file, the selection you make in the gui will override the output: setting.

You can also use the output: value to render your document as a slideshow.

  • output: ioslides_presentation will create an ioslides (HTML5) slideshow
  • output: beamer_presentation will create a beamer (PDF) slideshow

Note: The knit button in the RStudio IDE will update to show slideshow options when you include one of the above output values and save your .Rmd file.

rmarkdown will convert your document into a slideshow by starting a new slide at each header or horizontal rule (e.g., *** ).

Visit rmakdown.rstudio.com to learn about more YAML options that control the render process.

R Markdown documents provide quick, reproducible reporting from R. You write your document in markdown and embed executable R code chunks with the knitr syntax.

You can update your document at any time by re-knitting the code chunks.

You can then convert your document into several common formats.

R Markdown documents implement Donald’s Knuth’s idea of literate programming and take the manual labor out of writing and maintaining reports. Moreover, they are quick to learn. You already know ecnough about markdown, knitr, and YAML to begin writing your own R Markdown reports.

In the next article, Introduction to interactive documents , you will learn how to add interactive Shiny components to an R Markdown report. This creates a quick workflow for writing light-weight Shiny apps.

To learn more about R Markdown and interactive documents, please visit rmarkdown.rstudio.com .

background picture with networks

Turn messy R scripts into clean interactive reproducible online reports

An interactive mini course helping R developers be So. Much. More. efficient at data analysis.

The struggle is real

For the 10th time you open your script called my_analysis_final2.R .

You're ready for a last run, creating a few graphs that you will have to copy paste to your report, together with some crucial statistical test results.

Did you really write this? It is barely readable . There are no comments. Some lines are so long you can't see their ends. It basically looks like a labyrinth of duplication, making even the smallest changes an agonizing ordeal.

But wait 🤔. Where is the awesome piece of code you wrote the other day? Perhaps in another version of the script...

Nevermind, let's email those results to the team, it is not too bad already. At least you did not lose your script like last time.

You run the analysis on data_clean.csv instead of data_final.csv . Results are all wrong ! 🙈

There is an easier way!

I remember those good old days so well.

But some tools can make your life 100x easier 🎉

Quarto transforms your code in a stunning report. HTML widgets integrate interactive charts in it. Git tracks all your changes. Github hosts your work and transforms it in a website for free.

In this mini course, I provide you with an efficient pipeline for your daily data analysis work with R. An elixir of the best tools, tips and tricks.

I promise there won't be any coming back.

🔥 Let's build a

🧹 Clean your code

My 10 very practical tips to greatly improve your coding skills.

Learn how to create a function , how to use a linter , how to organize your project and avoid common mistakes.

🎨 Interactivity and polish

Go beyond the default report.

Learn how to create a theme , make your report pretty , include interactive charts , and heaps of web development tips.

Let's make your colleagues enjoy reading your work!

🚀 Publish & Store online

Learn how to store your analysis online, and transform your report in a website .

Foster collaboration, reproducibility, and code sharing.

Update your work and everyone will access it without sending one more email!

📖 Make it a report

Stop copy-pasting results and figures.

Learn how to create a reproducible report from your code. It will contain code , explanation , results and graphs .

🧐 Track your changes

Let's stop creating data2.csv and data3.csv .

Learn the very basics of git , allowing to keep track of every single step of your progress.

You will never lose your work again.

Get a Clean, Interactive, Reproducible, Online report

Fork the project. Click 1 button. → Everything runs again.

Use the theme provided by the course. Plus some web dev tips.

Code and report are available for free on the web. For free.

Include tabs, interactive charts, links, maps, and more.

A picture of a testimonial

This is such an amazing course that will help you streamline those R projects and develop good data practices! So happy to have joined the first group, it made my life so much easier !

Postdoctoral economist, Institute for the Future of Work

A picture of a testimonial

The course provides concrete tools to convert the analyses you do in R into more readable and shareable reports. You get an A to Z method of creating a reproducible project, the focus is on R, but the creative mind can also apply this elsewhere. The whole thing is brought into small directly applicable modules, which immediately have a big impact on your workflow.

Finance consultant, Eiffel

🎮 Interactive learning experience 🎮

This course is not a book or a set of boring videos! I tried to make learning fun and interactive . For instance, check your R knowledge with this quizz! 😀.

What is the primary use of ggplot2 ?

What is the purpose of StyleR ?

In a Quarto document, how do you create an executable R code chunk?

In R, what is the correct syntax to define a function named calculateSum that takes two arguments and returns their sum?

What is the Tidyverse ?

Name three core principles that the Tidyverse packages adhere to.

How do you install a package from GitHub in R?

Which package in the Tidyverse is primarily used for data manipulation?

In a Quarto document, how do you link to an external CSS file?

How do you update your local repository to match the remote repository in Git?

What shortcut is used to run a line of R code in RStudio?

How do you write text in bold in Markdown?

Is Shiny required to create a document with interactive graphs?

Do you need to pay to share your data analysis report via GitHub?

Is it possible to read an xlsx file in R without converting it to CSV format?

Is building an interactive graph in R typically a complex task requiring at least 100 lines of code?

Should an R script always begin with the setwd() function?

What role does CSS play in relation to Quarto documents?

What is GitHub Desktop?

Is RStudio required to use Quarto?

👋 Hi! I'm Yan Holtz.

Senior Software Engineer in ❤️ with educational content.

A picture of Yan Holtz

With over a decade of hands-on experience in data analysis and software engineering, I've had the privilege of working in various tech companies and research labs globally.

You might recognize me from my widely-visited educational platforms like the R , Python , D3.js , and React Graph Galleries, as well as my award-winning projects Data-to-Viz.com and Dataviz-Inspiration.com .

Frequently, people approach me seeking guidance on their R journey. This course is my comprehensive, well-structured response, born from a broad and deep understanding of the field.

Spend just a few hours of your time with me! I guarantee that the productivity gains will quickly offset the initial investment 🔥.

A picture of a testimonial

Yan's recent talk showcased his R programming course, brilliantly tailored for beginners. Leveraging his deep expertise in the R ecosystem and common challenges, the course is a perfect launchpad to boost productivity in R .

CTO of ThinkR

A picture of a testimonial

I only finished module 2 lesson 3 so far, but already feel like I have got value for my money. The course is informative, yet easy to follow. Yan and the welcoming community on Discord help me when I need it. I look forward to learning even more from Yan as I progress through the course.

Associate Risk Consultant, Marsh Advisory Nordics

🔥 Early Access

The initial version of the course is now available! Act fast to secure your spot at the current price, as it will double upon the full completion of the course!

Early Access

Price will double upon course completion

A picture of a testimonial

R is a fantastic but permissive language; it's hard not to make errors in reproducibility. What I loved about Yan's talk is his way of simply presenting the best R practices that can be game-changing for your statistical work even if you are a beginner!

Project Leader, French National Institute of Statistics

A picture of a testimonial

R resources are abundant online, but Yan's project truly enhanced my skills. Thanks to it, I transitioned from simple R knowledge to mastering speed, reliability, and clarity in my storytelling . This is the most changing game I've been to in terms of dataviz and comprehension .

Revenue Growth Specialist, Adevinta

Frequently asked questions

How long will it take to complete the course?

Is there a slack or discord group, how much prior knowledge do i need, how can i get reimbursed by my employer, i am into python, not r. should i join, are there discounts available, i want my money back, when will be the course ready, do you make group offers, i have a question not listed here.

interactive: Is R Running Interactively?

Description.

Return TRUE when R is being used interactively and FALSE otherwise.

An interactive R session is one in which it is assumed that there is a human operator to interact with, so for example R can prompt for corrections to incorrect input or ask what to do next or if it is OK to move to the next plot.

GUI consoles will arrange to start R in an interactive session. When R is run in a terminal (via Rterm.exe on Windows), it assumes that it is interactive if stdin is connected to a (pseudo-)terminal and not if stdin is redirected to a file or pipe. Command-line options --interactive (Unix) and --ess (Windows, Rterm.exe ) override the default assumption. (On a Unix-alike, whether the readline command-line editor is used is not overridden by --interactive .)

Embedded uses of R can set a session to be interactive or not.

Internally, whether a session is interactive determines

how some errors are handled and reported, e.g.see stop and options ("showWarnCalls") .

whether one of --save , --no-save or --vanilla is required, and if R ever asks whether to save the workspace.

the choice of default graphics device launched when needed and by dev.new : see options ("device")

whether graphics devices ever ask for confirmation of a new page.

In addition, R 's own R code makes use of interactive() : for example help , debugger and install.packages do.

source , .First

Run the code above in your browser using DataCamp Workspace

  • CBSSports.com
  • Fanatics Sportsbook
  • CBS Sports Home
  • NCAA Tournament
  • W. Tournament
  • Champions League
  • Motor Sports
  • High School
  • Horse Racing 

mens-brackets-180x100.jpg

Men's Brackets

womens-brackets-180x100.jpg

Women's Brackets

Fantasy Baseball

Fantasy football, football pick'em, college pick'em, fantasy basketball, fantasy hockey, franchise games, 24/7 sports news network.

cbs-sports-hq-watch-dropdown.jpg

  • CBS Sports Golazo Network
  • March Madness Live
  • PGA Tour on CBS
  • UEFA Champions League
  • UEFA Europa League
  • Italian Serie A
  • Watch CBS Sports Network
  • TV Shows & Listings

The Early Edge

201120-early-edge-logo-square.jpg

A Daily SportsLine Betting Podcast

With the First Pick

wtfp-logo-01.png

NFL Draft is coming up!

  • Podcasts Home
  • Eye On College Basketball
  • The First Cut Golf
  • NFL Pick Six
  • Cover 3 College Football
  • Fantasy Football Today
  • Morning Kombat
  • My Teams Organize / See All Teams Help Account Settings Log Out

2024 MLB hot seat: 11 managers whose job could be on the line, including Aaron Boone and Dave Roberts

It's never too early to check in on who's under the most pressure in the dugout this season.

boone-usatsi.png

The 2024 Major League Baseball season is already upon us and is beautifully and mercifully still young. As such, it may seem indecent to soil matters by tacitly calling to mind things like exit interviews and COBRA plans and feverishly googled unemployment policies and LinkedIn password-reset prompts and lying through a viscous sludge of snot and tears – lying to everyone, most especially yourself – on social media that you're "looking forward to what's next." Alas and alack, we're here to do just that. 

We're here to do just that by reluctantly declaring which big-league managers may be going into the 2024 season on hot seats of varying temperatures. None of this is to suggest these forthcoming skippers deserve such straits or that will inevitably be terminated. Rather, it's just a laundry-list of managers who may be in peril if the 2024 season doesn't yield the desired or at least the respective results for their respective clubs. 

Before we begin, let's note that Cardinals manager Oli Marmol would've been prominently placed on this list had he not recently signed a surprise contract extension through the 2026 season . Coming off the Cardinals' first losing season since 2007 and first 90-loss season since 1990, Marmol definitely seemed imperiled going into 2024. While managers can be and have been defenestrated while under contract, Marmol is probably safe for the timespan in question. 

Now on to the chosen hot seaters for 2024, listed in suspense-filled alphabetical order. 

Bud Black, Rockies

Black probably isn't in grave danger given how the Rockies do things. Still, let's note that Black has guided the Rockies to five straight losing seasons, and their record has steadily gotten worse. Last year, Black and the Rockies endured a franchise-record 103 losses, and the 2024 model projects to be similarly terrible. It's fair to wonder whether Black would survive such depths again, 

Aaron Boone, Yankees

The Yankees are coming off an 82-win season in 2023, which was their worst season since 1992. Early this past offseason, Boone's job was widely thought to be in danger, but that turned out not to be the case. If he's to be the Yanks' skipper beyond 2024, however, significant improvement in the standings will be required. With Juan Soto notably added to the fold, expectations are high in the Bronx, and Boone must meet them. 

Alex Cora, Red Sox

Cora is in the final year of his contract with Boston, so if things go awry this could be more a case of letting him walk at the end of the season rather than terminating him. For our purposes, though, it's close enough. Boston's problem is owner John Henry's lack of interest in fielding a playoff-worthy roster, but as we know blame for the failures of ownership and the front office often accrue to the manager. It's possible the Red Sox are headed for a third straight last-place finish in the AL East, and Cora may not survive such a thing. 

Pedro Grifol, White Sox

Grifol's first season on the South Side occasioned 101 losses and rumors of clubhouse dysfunction. Now leaning into a rebuild under new GM Chris Getz, the Sox will almost certainly be terrible in 2024. Even though the Sox are almost certainly bound for last place in baseball's weakest division, Grifol's status may hinge on improved vibes and whether he can oversee improved performances from some of the team's remaining veterans leading up to the trade deadline. 

A.J. Hinch, Tigers

Hinch is now in his fourth full season as Detroit's manager, and he's still seeking his first winning season. To be fair, that's in line with expectations given the rosters the Tigers have trotted out in recent years. Even so, Hinch was hired before president of baseball operations Scott White was, and when a manager isn't the hand-picked choice of the team's baseball-ops leader it's always a situation worth monitoring. Hinch doesn't necessarily need to oversee a surprise playoff run to keep his job, but improvement and perhaps a winning season may be required of him 

Mark Kotsay, A's

Obviously, you can't blame Kotsay for the rank and cynical efforts at sabotage by John Fisher, the sport's worst owner (and a competitive category, that one). Still, we can't entirely skate around the fact that the A's under Kotsay have won just a bit more than 33% of his games. Framed another way, Kotsay, even though he's managed barely more than two seasons, is already one of just 49 big-league managers to be 100 or more games under .500. To repeat, the strip-mined roster is to blame for all of this, but managers are typically the first scapegoat in line.  

Dave Martinez, Nationals

Martinez has a ring as Nats manager, but that feels like a very long time ago. Since then, Martinez and the Nats have endured four straight losing seasons. They "improved" to 71-91 last season from the depths of their 107-loss campaign in 2022. However, this year's club projects to be one of the worst in baseball. If that indeed comes to pass, then Martinez could be in danger. 

Dave Roberts, Dodgers

It feels absurd to have Roberts on this list. In eight full seasons on the job, he's guided the Dodgers to eight playoff berths, seven division titles, one World Series triumph in the abbreviated 2020 season, and two additional pennants. Over that span, Roberts has won a whopping 63.1% of his games. Among managers with at least 1,000 career games, Roberts is first in career winning percentage. All that said, there's immense pressure on Roberts and the Dodgers to win it all this season. That's what happens when you add the likes of Shohei Ohtani, Yoshinobu Yamamoto, and Tyler Glasnow, among others, to an already powerhouse roster. Since winning it all in 2020, the Dodgers are 7-12 in the postseason and have been bounced in the opening round in each of the last two years. Another early exit could cost Roberts his job, as unlikely as that sounds. 

John Schneider, Blue Jays

Schneider has led Toronto to the postseason in each of his two years on the job. However, they're 0-4 in the playoffs in that span. After last year's Wild Card Series sweep at the hands of the Twins, Schneider and GM Ross Atkins seemed to not be on the same page in terms of pitching decisions in those playoffs. As such Schneider's future in the Toronto dugout may depend not only on getting the Jays into the postseason for a third straight year but also getting them deep into October. 

Scott Servais, Mariners 

Servais certainly isn't in immediate danger. After all, in 2022 he piloted the Mariners to their first playoff berth in more than two decades, and they've notched three straight winning seasons on his watch. As well, Servais has a close relationship with head of baseball ops Jerry Dipoto. That said, the M's are built to win – as much as they can be in light of ownership's lacking commitment, anyway – and if they miss the playoffs for a second straight year, then Servais could be in trouble. 

Derek Shelton, Pirates

This one may be a reach. The Pirates have improved their winning percentage in every season of Shelton's tenure, which is precisely what you want from a rebuilding project. Even so, the young talent has largely trickled in – Paul Skenes notwithstanding – and even more forward progress is expected. It's unfair to say the Pirates need to make the postseason in 2024, but relevance in the NL Central and perhaps a winning season are reasonable expectations for Shelton. 

Now with those endangered names laid out, please do go forth into the world and in a towering gesture of sympathy and solidarity get fired from your job. 

Our Latest MLB Stories

mookie-usatsi.png

Ranking MLB teams by pressure to win in 2024

Mike axisa • 10 min read.

jung-getty.png

Rangers' Josh Jung breaks wrist on HBP

R.j. anderson • 1 min read.

yankees-2024-still-vs-dbacks.png

Yankees (5-0) off to best start since 1992

blake-snell-giants-spring-training-2024.png

Snell to make debut for Giants on Monday

gerrit-cole-yankees.jpg

Brewers vs. Twins odds, picks, computer sims

Cbs sports staff • 3 min read.

jazz-usatsi.png

Chisholm blames open roof, shadows for Marlins sweep

Share video.

r report interactive

Who's on the MLB managerial hot seat in 2024?

r report interactive

Ranking teams by pressure to win

r report interactive

Ohtani and Mizuhara's timeline

r report interactive

Cubs' Imanaga takes no-hitter into sixth in debut

r report interactive

Report: White Sox to sign Mike Clevinger

r report interactive

Dodgers' Buehler has return timeline coming into focus

r report interactive

Ranking MLB's top 100 players for 2024 season

  • Share full article

Advertisement

​Why School Absences Have ‘Exploded’ Almost Everywhere

The pandemic changed families’ lives and the culture of education: “Our relationship with school became optional.”

By Sarah Mervosh and Francesca Paris

Sarah Mervosh reports on K-12 education, and Francesca Paris is a data reporter.

In Anchorage, affluent families set off on ski trips and other lengthy vacations, with the assumption that their children can keep up with schoolwork online.

In a working-class pocket of Michigan, school administrators have tried almost everything, including pajama day, to boost student attendance.

And across the country, students with heightened anxiety are opting to stay home rather than face the classroom.

In the four years since the pandemic closed schools, U.S. education has struggled to recover on a number of fronts, from learning loss , to enrollment , to student behavior .

But perhaps no issue has been as stubborn and pervasive as a sharp increase in student absenteeism, a problem that cuts across demographics and has continued long after schools reopened.

Nationally, an estimated 26 percent of public school students were considered chronically absent last school year, up from 15 percent before the pandemic, according to the most recent data, from 40 states and Washington, D.C., compiled by the conservative-leaning American Enterprise Institute . Chronic absence is typically defined as missing at least 10 percent of the school year, or about 18 days, for any reason.

Source: Upshot analysis of data from Nat Malkus, American Enterprise Institute. Districts are grouped into highest, middle and lowest third.

The increases have occurred in districts big and small, and across income and race. For districts in wealthier areas, chronic absenteeism rates have about doubled, to 19 percent in the 2022-23 school year from 10 percent before the pandemic, a New York Times analysis of the data found.

Poor communities, which started with elevated rates of student absenteeism, are facing an even bigger crisis: Around 32 percent of students in the poorest districts were chronically absent in the 2022-23 school year, up from 19 percent before the pandemic.

Even districts that reopened quickly during the pandemic, in fall 2020, have seen vast increases.

“The problem got worse for everybody in the same proportional way,” said Nat Malkus, a senior fellow at the American Enterprise Institute, who collected and studied the data.

r report interactive

Victoria, Texas reopened schools in August 2020, earlier than many other districts. Even so, student absenteeism in the district has doubled.

Kaylee Greenlee for The New York Times

The trends suggest that something fundamental has shifted in American childhood and the culture of school, in ways that may be long lasting. What was once a deeply ingrained habit — wake up, catch the bus, report to class — is now something far more tenuous.

“Our relationship with school became optional,” said Katie Rosanbalm, a psychologist and associate research professor with the Center for Child and Family Policy at Duke University.

The habit of daily attendance — and many families’ trust — was severed when schools shuttered in spring 2020. Even after schools reopened, things hardly snapped back to normal. Districts offered remote options, required Covid-19 quarantines and relaxed policies around attendance and grading .

Source: Nat Malkus, American Enterprise Institute . Includes districts with at least 1,500 students in 2019. Numbers are rounded. U.S. average is estimated.

Today, student absenteeism is a leading factor hindering the nation’s recovery from pandemic learning losses , educational experts say. Students can’t learn if they aren’t in school. And a rotating cast of absent classmates can negatively affect the achievement of even students who do show up, because teachers must slow down and adjust their approach to keep everyone on track.

“If we don’t address the absenteeism, then all is naught,” said Adam Clark, the superintendent of Mt. Diablo Unified, a socioeconomically and racially diverse district of 29,000 students in Northern California, where he said absenteeism has “exploded” to about 25 percent of students. That’s up from 12 percent before the pandemic.

r report interactive

U.S. students, overall, are not caught up from their pandemic losses. Absenteeism is one key reason.

Why Students Are Missing School

Schools everywhere are scrambling to improve attendance, but the new calculus among families is complex and multifaceted.

At South Anchorage High School in Anchorage, where students are largely white and middle-to-upper income, some families now go on ski trips during the school year, or take advantage of off-peak travel deals to vacation for two weeks in Hawaii, said Sara Miller, a counselor at the school.

For a smaller number of students at the school who qualify for free or reduced-price lunch, the reasons are different, and more intractable. They often have to stay home to care for younger siblings, Ms. Miller said. On days they miss the bus, their parents are busy working or do not have a car to take them to school.

And because teachers are still expected to post class work online, often nothing more than a skeleton version of an assignment, families incorrectly think students are keeping up, Ms. Miller said.

Sara Miller sits at a desk, with trophies on the shelves and a computer in front of her.

Sara Miller, a counselor at South Anchorage High School for 20 years, now sees more absences from students across the socioeconomic spectrum.

Ash Adams for The New York Times

Across the country, students are staying home when sick , not only with Covid-19, but also with more routine colds and viruses.

And more students are struggling with their mental health, one reason for increased absenteeism in Mason, Ohio, an affluent suburb of Cincinnati, said Tracey Carson, a district spokeswoman. Because many parents can work remotely, their children can also stay home.

For Ashley Cooper, 31, of San Marcos, Texas, the pandemic fractured her trust in an education system that she said left her daughter to learn online, with little support, and then expected her to perform on grade level upon her return. Her daughter, who fell behind in math, has struggled with anxiety ever since, she said.

“There have been days where she’s been absolutely in tears — ‘Can’t do it. Mom, I don’t want to go,’” said Ms. Cooper, who has worked with the nonprofit Communities in Schools to improve her children’s school attendance. But she added, “as a mom, I feel like it’s OK to have a mental health day, to say, ‘I hear you and I listen. You are important.’”

Experts say missing school is both a symptom of pandemic-related challenges, and also a cause. Students who are behind academically may not want to attend, but being absent sets them further back. Anxious students may avoid school, but hiding out can fuel their anxiety.

And schools have also seen a rise in discipline problems since the pandemic, an issue intertwined with absenteeism.

Dr. Rosanbalm, the Duke psychologist, said both absenteeism and behavioral outbursts are examples of the human stress response, now playing out en masse in schools: fight (verbal or physical aggression) or flight (absenteeism).

Quintin Shepherd stands for a portrait, dressed in a gray blazer and white shirt. Behind him are large bookcases, filled with photos, awards and books.

“If kids are not here, they are not forming relationships,” said Quintin Shepherd, the superintendent in Victoria, Texas.

Quintin Shepherd, the superintendent in Victoria, Texas, first put his focus on student behavior, which he described as a “fire in the kitchen” after schools reopened in August 2020.

The district, which serves a mostly low-income and Hispanic student body of around 13,000, found success with a one-on-one coaching program that teaches coping strategies to the most disruptive students. In some cases, students went from having 20 classroom outbursts per year to fewer than five, Dr. Shepherd said.

But chronic absenteeism is yet to be conquered. About 30 percent of students are chronically absent this year, roughly double the rate before the pandemic.

Dr. Shepherd, who originally hoped student absenteeism would improve naturally with time, has begun to think that it is, in fact, at the root of many issues.

“If kids are not here, they are not forming relationships,” he said. “If they are not forming relationships, we should expect there will be behavior and discipline issues. If they are not here, they will not be academically learning and they will struggle. If they struggle with their coursework, you can expect violent behaviors.”

Teacher absences have also increased since the pandemic, and student absences mean less certainty about which friends and classmates will be there. That can lead to more absenteeism, said Michael A. Gottfried, a professor at the University of Pennsylvania Graduate School of Education. His research has found that when 10 percent of a student’s classmates are absent on a given day, that student is more likely to be absent the following day.

A large atrium like hallway, with students and teachers milling about.

Absent classmates can have a negative impact on the achievement and attendance of even the students who do show up.

Is This the New Normal?

In many ways, the challenge facing schools is one felt more broadly in American society: Have the cultural shifts from the pandemic become permanent?

In the work force, U.S. employees are still working from home at a rate that has remained largely unchanged since late 2022 . Companies have managed to “put the genie back in the bottle” to some extent by requiring a return to office a few days a week, said Nicholas Bloom, an economist at Stanford University who studies remote work. But hybrid office culture, he said, appears here to stay.

Some wonder whether it is time for schools to be more pragmatic.

Lakisha Young, the chief executive of the Oakland REACH, a parent advocacy group that works with low-income families in California, suggested a rigorous online option that students could use in emergencies, such as when a student misses the bus or has to care for a family member. “The goal should be, how do I ensure this kid is educated?” she said.

Students, looking tired, sit at their desks, back to the camera.

Relationships with adults at school and other classmates are crucial for attendance.

In the corporate world, companies have found some success appealing to a sense of social responsibility, where colleagues rely on each other to show up on the agreed-upon days.

A similar dynamic may be at play in schools, where experts say strong relationships are critical for attendance.

There is a sense of: “If I don’t show up, would people even miss the fact that I’m not there?” said Charlene M. Russell-Tucker, the commissioner of education in Connecticut.

In her state, a home visit program has yielded positive results , in part by working with families to address the specific reasons a student is missing school, but also by establishing a relationship with a caring adult. Other efforts — such as sending text messages or postcards to parents informing them of the number of accumulated absences — can also be effective.

Regina Murff, in a tan blazer, stands by the doorway of her home.

Regina Murff has worked to re-establish the daily habit of school attendance for her sons, who are 6 and 12.

Sylvia Jarrus for The New York Times

In Ypsilanti, Mich., outside of Ann Arbor, a home visit helped Regina Murff, 44, feel less alone when she was struggling to get her children to school each morning.

After working at a nursing home during the pandemic, and later losing her sister to Covid-19, she said, there were days she found it difficult to get out of bed. Ms. Murff was also more willing to keep her children home when they were sick, for fear of accidentally spreading the virus.

But after a visit from her school district, and starting therapy herself, she has settled into a new routine. She helps her sons, 6 and 12, set out their outfits at night and she wakes up at 6 a.m. to ensure they get on the bus. If they are sick, she said, she knows to call the absence into school. “I’ve done a huge turnaround in my life,” she said.

But bringing about meaningful change for large numbers of students remains slow, difficult work .

r report interactive

Nationally, about 26 percent of students were considered chronically absent last school year, up from 15 percent before the pandemic.

The Ypsilanti school district has tried a bit of everything, said the superintendent, Alena Zachery-Ross. In addition to door knocks, officials are looking for ways to make school more appealing for the district’s 3,800 students, including more than 80 percent who qualify for free or reduced-price lunch. They held themed dress-up days — ’70s day, pajama day — and gave away warm clothes after noticing a dip in attendance during winter months.

“We wondered, is it because you don’t have a coat, you don’t have boots?” said Dr. Zachery-Ross.

Still, absenteeism overall remains higher than it was before the pandemic. “We haven’t seen an answer,” she said.

Data provided by Nat Malkus, with the American Enterprise Institute. The data was originally published on the Return to Learn tracker and used for the report “ Long COVID for Public Schools: Chronic Absenteeism Before and After the Pandemic .”

The analysis for each year includes all districts with available data for that year, weighted by district size. Data are sourced from states, where available, and the U.S. Department of Education and NCES Common Core of Data.

For the 2018-19 school year, data was available for all 50 states and the District of Columbia. For 2022-23, it was available for 40 states and D.C., due to delays in state reporting.

Closure length status is based on the most in-person learning option available. Poverty is measured using the Census Bureau’s Small Area Income and Poverty Estimates. School size and minority population estimates are from NCES CCD.

How absenteeism is measured can vary state by state, which means comparisons across state lines may not be reliable.

An earlier version of this article misnamed a research center at Duke University. It is the Center for Child and Family Policy, not the Center of Child and Family Policy.

IMAGES

  1. R Tutorial 12. Create Report in R| Interactive reporting with R |latest package in R

    r report interactive

  2. How to Create Interactive Reports in R Markdown Part II: Data

    r report interactive

  3. Interactive reports in R with knitr and RStudio

    r report interactive

  4. 40 Reports with R Markdown

    r report interactive

  5. Create A R Shiny App Or Dashboard

    r report interactive

  6. Why You Should Use Interactive Report? A Complete Guide

    r report interactive

VIDEO

  1. How do you retain talent as your workforce gets older?

  2. DEL w vs UP w Dream11 Grand League Team Today Prediction, UP w vs DEL w Dream11: Fantasy Tips

  3. Pre Market Report 05-Mar-2024

  4. Unveiling the Dark Truth Behind THE A&R REPORT

  5. R. Report Final Draft PVAMU

  6. Oracle BI Publisher

COMMENTS

  1. 2.8 Interactive documents

    The first official book authored by the core R Markdown developers that provides a comprehensive and accurate reference to the R Markdown ecosystem. With R Markdown, you can easily create reproducible data analysis reports, presentations, dashboards, interactive applications, books, dissertations, websites, and journal articles, while enjoying the simplicity of Markdown and the great power of ...

  2. Introduction to interactive documents

    Turn your analyses into high quality documents, reports, presentations and dashboards with R Markdown. Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL. R Markdown supports a reproducible workflow for dozens of static and dynamic output formats including HTML, PDF, MS Word ...

  3. Interactive Documents

    Turn your analyses into high quality documents, reports, presentations and dashboards with R Markdown. Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL. R Markdown supports a reproducible workflow for dozens of static and dynamic output formats including HTML, PDF, MS Word ...

  4. 40 Reports with R Markdown

    40. Reports with R Markdown. R Markdown is a widely-used tool for creating automated, reproducible, and share-worthy outputs, such as reports. It can generate static or interactive outputs, in Word, pdf, html, powerpoint, and other formats. An R Markdown script intersperces R code and text such that the script actually becomes your output document.

  5. How to create interactive HTML reports using R

    In this post, I will explain how to create interactive HTML reports including widgets such as maps and interactive graphs using R. I assume that the reader is familiar with basic R. I will use two public APIs from the Environment Agency to download data, the Water Quality Archive for water quality data (phosphate in this example) and the ...

  6. How to Create Interactive Reports in R Markdown Part II: Data ...

    Interactive Data Visualisation ggiraph. ggiraph is the first package we will look at in order to create our interactive visuals. This package allows you create interactive layers within a ggplot ...

  7. R Markdown

    Turn your analyses into high quality documents, reports, presentations and dashboards with R Markdown. Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL. R Markdown supports a reproducible workflow for dozens of static and dynamic output formats including HTML, PDF, MS Word ...

  8. Using HTML Widgets for R to Create Interactive Reports

    Many people who work with R for data analysis use the powerful ggplot2 package to create graphs and charts. ggplotly converts a ggplot2 object to a plotly object. plotly is a graphing library for making interactive, high-quality graphs. In the example below, a ggplot2 object showing a bar chart of university library book counts was passed ...

  9. Creating Reports with R Markdown. An explanation of writing a report

    Knitting R Markdown to Retrieve The Report. For you to knit R Markdown files, you may need to install a few packages. R studio will automatically detect that you are missing the necessary packages and it will ask you to download them. There are three ways of outputting your report. HTML; PDF; MS Word

  10. How to Create Interactive Reports with R Markdown Part I:

    Initial Setup. To start an RMarkdown document: Select the new file icon and then R Markdown. In the options box alter the title and author if you wish, then select OK. It will open with a sample ...

  11. Shiny

    Interactive documents are a new way to build Shiny apps. An interactive document is an R Markdown file that contains Shiny widgets and outputs. You write the report in markdown, and then launch it as an app with the click of a button.. R Markdown. The previous article, Introduction to R Markdown, described how to write R Markdown files.R Markdown files are useful because

  12. Creating an interactive report using R and shiny

    Creating an interactive report using R and shiny. The following article describes my journey on building a shiny app for data visualization during my internship at arconsis. The used data is from ...

  13. Interactive Reporting

    With a dynamic report, you give the reader the tools to answer their own questions. Get started by learning how to make your R Markdown documents interactive, and then unleash the full flexibility of analytic app development with shiny. Embedding Shiny Apps in R Markdown documents - Garrett Grolemund. Shiny: R made interactive - Joe Cheng.

  14. How To Create Reports In R: A Step-By-Step Approach

    Using R Markdown. Using R Markdown: R Markdown allows you to integrate R code with narrative text, creating a dynamic report. Start by creating a new R Markdown file in RStudio. # In RStudio, go to File > New File > R Markdown... 📌. This action opens a dialog to set up a new R Markdown file.

  15. How To Create Interactive Visualizations In R: A Step-By ...

    Creating basic interactive charts in R is a straightforward process, especially with the plotly package. This package transforms static ggplot2 charts into interactive visualizations. First, ensure you have plotly installed and loaded: install.packages ("plotly") # Install plotly. library ( plotly) # Load plotly.

  16. Revolutionizing Clinical Research with Interactive Reports ...

    The introduction of innovative tools like Shiny and Quarto has empowered researchers and data scientists to transform complex data into interactive and insightful reports. This progress is not just an improvement in data visualization but a significant leap towards a new paradigm in clinical research. In this article, we'll delve into the core functionalities of […] The post appeared first ...

  17. R Markdown Automated Reports (And Easier Ways to Automate)

    This includes removing any interactive elements and ensuring that all data sources can be accessed automatically. ... Step-by-Step Guide to Building an Automated R Markdown Report. Step 1: Install Necessary Packages. The first step is to install the necessary packages. You'll need the markdown package for creating the report, and depending on ...

  18. Data Visualization Reloaded: Equipping Your Reports with the Ultimate R

    In the vast and ever-expanding universe of data, the ability to not just see but truly understand the stories hidden within numbers becomes paramount. This journey of comprehension isn't unlike the iconic moment from The Matrix, where Neo, standing amidst the endless possibilities of the digital realm, declares his need for "Guns, lots of guns." In the context of our exploration, these ...

  19. 28 Reports

    11.24 R Programming for Data Science. 11.25 Targeted Learning in R: Causal Data Science with the tlverse Software Ecosystem. 11.26 The Art of Data Science. 11.27 The Elements of Data Analytic Style. 11.28 Yet Again: R + Data Science. 11.29 Yet another 'R for Data Science' study guide. 12 Data Visualization.

  20. Introduction to R Markdown

    The companion article, Introduction to interactive documents, will show you how to turn an R Markdown report into an interactive document with Shiny components. R Markdown. R Markdown is a file format for making dynamic documents with R. An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of ...

  21. Productive R workflow

    There is an easier way! I remember those good old days so well. But some tools can make your life 100x easier 🎉. Quarto transforms your code in a stunning report. HTML widgets integrate interactive charts in it. Git tracks all your changes.Github hosts your work and transforms it in a website for free.. In this mini course, I provide you with an efficient pipeline for your daily data ...

  22. 41 Organizing routine reports

    41. Organizing routine reports. This page covers the reportfactory package, which is an accompaniment to using R Markdown for reports. In scenarios where you run reports routinely (daily, weekly, etc.), it eases the compilation of multiple R Markdown files and the organization of their outputs. In essence, it provides a "factory" from which ...

  23. interactive function

    An interactive R session is one in which it is assumed that there is a human operator to interact with, so for example R can prompt for corrections to incorrect input or ask what to do next or if it is OK to move to the next plot. GUI consoles will arrange to start R in an interactive session.

  24. How To Create Interactive Reports In R Markdown Part III ...

    Finally, check how the report looks on different platforms (laptop, mobile, tablet etc.). Plotly, when run through R, doesn't seem to render well on mobile devices for example. Reactive Plots ...

  25. WWE SmackDown Results: Winners, Live Grades, Reaction ...

    Welcome to Bleacher Report's live coverage of WWE SmackDown on March 29. We are just over a week away from WrestleMania XL on April 6 and 7, so practically…

  26. Men's NCAA Tournament 2024: B/R Expert Predictions for Elite Eight

    All eight top-two seeds entered the Sweet 16—only the fifth time in the 64-team era—but only three are headed to the Elite Eight of the 2024 men's NCAA…

  27. White Sox reunite with pitcher Mike Clevinger, per report, adding to

    With the 9-0 loss in Monday's game to the powerhouse Atlanta Braves (Gametracker), Chicago has started the season 0-4 and scored a total of eight runs.The White Sox went 61-101 in 2023.

  28. How the Key Bridge Collapsed in Baltimore: Maps and Photos

    The Francis Scott Key Bridge was opened in 1977 and carried more than 12.4 million vehicles last year. The bridge was one of the three major ways to cross the Patapsco River and formed part of ...

  29. 2024 MLB hot seat: 11 managers whose job could be on the line

    Pedro Grifol, White Sox. Grifol's first season on the South Side occasioned 101 losses and rumors of clubhouse dysfunction. Now leaning into a rebuild under new GM Chris Getz, the Sox will almost ...

  30. Why School Absences Have 'Exploded' Almost Everywhere

    The increases have occurred in districts big and small, and across income and race. For districts in wealthier areas, chronic absenteeism rates have about doubled, to 19 percent in the 2022-23 ...