Class12
Font Size
Font Size
Font Size
Font Size
Font Size
Font Size
Font Size (normal)
Bullet list
Item 1
Item 2
Item 3
Numeric List
Number 1
Number 2
Number 3
Running Code
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
1 + 1[1] 2
You can add options to executable code like this
[1] 4
The echo: false option disables the printing of code (only output is displayed).
Figure
Interactive Plot
library(plotly)Warning: package 'plotly' was built under R version 4.5.2
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
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 Unemployed"))plot_ly(
data=economics,
x = ~date,
y=~unemploy,
type="scatter",
mode="makers"
)plot_ly(
data=economics,
x=~unemploy,
type="histogram",
mode="makers"
)Warning: 'histogram' objects don't have these attributes: 'mode'
Valid attributes include:
'_deprecated', 'alignmentgroup', 'autobinx', 'autobiny', 'bingroup', 'cliponaxis', 'constraintext', 'cumulative', 'customdata', 'customdatasrc', 'error_x', 'error_y', 'histfunc', 'histnorm', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'insidetextanchor', 'insidetextfont', 'legend', 'legendgroup', 'legendgrouptitle', 'legendrank', 'legendwidth', 'marker', 'meta', 'metasrc', 'name', 'nbinsx', 'nbinsy', 'offsetgroup', 'opacity', 'orientation', 'outsidetextfont', 'selected', 'selectedpoints', 'showlegend', 'stream', 'text', 'textangle', 'textfont', 'textposition', 'textsrc', 'texttemplate', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'x', 'xaxis', 'xbins', 'xcalendar', 'xhoverformat', 'xsrc', 'y', 'yaxis', 'ybins', 'ycalendar', 'yhoverformat', 'ysrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
library(leaflet)
leaflet() %>%
addTiles()%>%
addMarkers(
lng=-84.39,
lat=33.75,
popup="Atlanta"
)Interactive Map
use in Project
leaflet() %>%
addTiles()%>%
addMarkers(
lng=-84.5184,
lat=33.9384,
popup="Kennesaw State University - Marietta Campus"
)Table
subcars <- mtcars[1:5,1:4]
knitr::kable(subcars,
col.names = c("Miles per Gallon","# of Cylinders","Engine Displacement","Horsepower"),
row.names = F,
caption = "Car Data")| Miles per Gallon | # 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 |
Interactive Table
library(DT)
datatable(mpg)