如题,代码如下:
---
title: "test"
author: "--"
date: '2022-05-24'
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## sparkline
```{r}
library(htmlwidgets)
library(sparkline)
set.seed(1234)
x = rnorm(10)
y = rnorm(10)
```
Inline line graphs `r sparkline(x)`
Bar charts `r sparkline(abs(x), type = 'bar')`
negative values: `r sparkline(x, type = 'bar')`
| Stock | Sparkline | Boxplot |
|:-----:|:-----------------:|:--------:|
| x | `r sparkline(x)` | `r sparkline(x, type ='box')`|
| y | `r sparkline(y)` | `r sparkline(y, type ='box')`|
生成的内容如下:
官方介绍的内容形如下图:
俺的环境信息如下:
> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] digest_0.6.28 R6_2.5.1 lifecycle_1.0.1 magrittr_2.0.2 evaluate_0.14 scales_1.1.1 rlang_1.0.2
[8] cli_3.2.0 DT_0.23 rmarkdown_2.11 tools_4.2.0 htmlwidgets_1.5.4 munsell_0.5.0 xfun_0.26
[15] yaml_2.2.1 fastmap_1.1.0 compiler_4.2.0 colorspace_2.0-2 htmltools_0.5.2 knitr_1.36