Listed below are the types of charts currently supported in **recharts**. If you are going to try any examples, please make sure you have loaded **recharts** in R:

`library(recharts)`

We can use a line chart when `x`

is numeric (or date/time) and `y`

is numeric. Below is an example of a single curve. We specified `type = 'line'`

, without which the plot will be a scatterplot.

```
# an example taken from ?curve
chippy = function(x) sin(cos(x)*exp(-x/2))
x = seq(-8, 7, length = 100)
echart(x = x, y = chippy(x), type = 'line')
```

An example of multiple lines using the `series`

argument (the four groups of data have the same correlation coefficient), and an example of a single time series:

```
# see ?anscombe for more info about this dataset
ans = as.matrix(anscombe)
ans = cbind(x = c(ans[, 1:4]), y = c(ans[, 5:8]), group = rep(1:4, each = 11))
ans = ans[order(ans[, 1]), ]
ans = as.data.frame(ans)
str(ans)
# 'data.frame': 44 obs. of 3 variables:
# $ x : num 4 4 4 5 5 5 6 6 6 7 ...
# $ y : num 4.26 3.1 5.39 5.68 4.74 5.73 7.24 6.13 6.08 4.82 ...
# $ group: num 1 2 3 1 2 3 1 2 3 1 ...
echart(ans, ~x, ~y, series = ~group, type = 'line')
```

`echart(y = nhtemp)`

When `x`

is character or factor, and `y`

is numeric or `NULL`

, `echart()`

will create a bar chart. An example using the `Titanic`

data and showing the survival rates in different classes:

```
(classSurv = aggregate(Freq ~ Class + Survived, as.data.frame(Titanic), sum))
# Class Survived Freq
# 1 1st No 122
# 2 2nd No 167
# 3 3rd No 528
# 4 Crew No 673
# 5 1st Yes 203
# 6 2nd Yes 118
# 7 3rd Yes 178
# 8 Crew Yes 212
echart(classSurv, ~Class, ~Freq, series = ~Survived)
```

An example showing the frequencies of some random numbers cut by 8 intervals:

```
x = cut(rnorm(1000), -4:4)
table(x)
# x
# (-4,-3] (-3,-2] (-2,-1] (-1,0] (0,1] (1,2] (2,3] (3,4]
# 1 13 123 377 332 127 26 1
echart(x = x)
```

When both `x`

and `y`

are numeric, `echart()`

produces a scatterplot by default. Here is a plot of the `faithful`

dataset:

`echart(faithful, ~eruptions, ~waiting)`