RMarkdown is a powerful tool that allows for seamless integration of text, code, and visualizations in a single document. This document explores its capabilities.
Inline R code: *“Today’s date is:* 2025-04-04.”
A simple calculation:
x <- 1:10
y <- x^2
data.frame(x, y)
## x y
## 1 1 1
## 2 2 4
## 3 3 9
## 4 4 16
## 5 5 25
## 6 6 36
## 7 7 49
## 8 8 64
## 9 9 81
## 10 10 100
RMarkdown supports LaTeX for mathematical equations.
\[ E = mc^2 \]
Inline math example: The function \(f(x) = x^2\) is quadratic!
library(ggplot2)
df <- data.frame(
category = c("A", "B", "C"),
value = c(15, 30, 10)
)
ggplot(df, aes(x = category, y = value, fill = category)) +
geom_bar(stat = "identity") +
theme_minimal() +
labs(title = "Bar Chart Example")
library(leaflet)
leaflet() %>%
addTiles() %>%
addMarkers(lng = -3.7038, lat = 40.4168, popup = "Madrid, Spain")
library(DT)
datatable(head(mtcars, 10), options = list(pageLength = 5))