First, you should load recharts
:
library(recharts)
Gauge is also known as dashboard.
The keys are:
x
y
facet
to yield multiple gaugest
if you want the gauge changeechartr(data, x, y, <series>, <facet>, <t>, <type>)
Arg | Requirement |
---|---|
data |
source data in the form of data.frame |
x |
character independent variable. Only the first one is accepted if multiple variables are provided. |
y |
numeric dependent variable. Only the first one is accepted. |
series |
series variable which will be coerced to factors. Each level of |
facet |
facetting variable which will be coerced to factors. Each level of |
t |
timeline variable which will be coerced to factors. Only the first one is accepted if multiple variables are provided. |
type |
‘gauge’ |
Here is a fictious dataset.
data = data.frame(x=rep(c('KR/min', 'Kph'), 2), y=c(6.3, 54, 7.5, 82),
z=c(rep('t1', 2), rep('t2', 2)))
knitr::kable(data)
x | y | z |
---|---|---|
KR/min | 6.3 | t1 |
Kph | 54.0 | t1 |
KR/min | 7.5 | t2 |
Kph | 82.0 | t2 |
echartr(data, x, y, type='gauge')
echartr(data, x, y, facet=x, type='gauge')
echartr(data, x, y, facet=x, t=z, type='gauge')
Then you can configure the widgets, add markLines and/or markPoints, fortify the chart.
You can refer to related functions to play around on your own.