Quarto Basics

Author

Amir Karami

Font Types

Header 1

Header 2

Header 3

Bullet List

  • Item 1

  • Item 2

Numeric List

  1. Item 1

  2. Item 2

Run Code

1+1
[1] 2
[1] 2
#install.packages("tidyverse")
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.1     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.2
✔ purrr     1.2.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
smaller <- diamonds |> 
  filter(carat <= 2.5)

smaller |> 
  ggplot(aes(x = carat)) + 
  geom_bar(binwidth = 0.01)
Warning in geom_bar(binwidth = 0.01): Ignoring unknown parameters: `binwidth`

Figure

Interactive Plots

More available at https://rstudio.github.io/dygraphs/index.html

library(plotly)

Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':

    last_plot
The following object is masked from 'package:stats':

    filter
The following object is masked from 'package:graphics':

    layout
#install.packages("plotly")
library(ggplot2)

data(economics)

plot_ly(
  data = economics,
  x = ~date,
  y = ~unemploy,
  type = "scatter",
  mode = "lines"
)%>%
  layout(
    xaxis = list(title = "Date"),
    yaxis = list(title = "Number of Unemployed")
  )
plot_ly(
  data = economics,
  x = ~date,
  y = ~unemploy,
  type = "scatter",
  mode = "markers"
)
plot_ly(
  data = economics,
  x = ~unemploy,
  type = "histogram"
)
#install.packages("leaflet")
library(leaflet)

leaflet() %>%
  addTiles() %>%   # base map
  addMarkers(
    lng = -84.39,
    lat = 33.75,
    popup = "Atlanta"
  )

Table

Project Deadlines
Project Phase Deadline
Team Creation Mar 31
Data Apr 6
Goal Apr 13
mtcars[1:5, ]
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
knitr::kable(mtcars[1:5, ], )
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
subcars <- mtcars[1:5,1:4]
knitr::kable(
  subcars,
  col.names = c("Miles per Gallon","Number of Cylinders",
                "Engine Displacement","Horsepower"),
  row.names = F,
  caption = "More Beautiful Car Data"
)
More Beautiful Car Data
Miles per Gallon Number of Cylinders Engine Displacement Horsepower
21.0 6 160 110
21.0 6 160 110
22.8 4 108 93
21.4 6 258 110
18.7 8 360 175
#install.packages('DT')
library(DT)
datatable(mpg)