Description Usage Arguments Details Value Author(s) Examples
Easily create a line chart
1 | line_chart(data, x, y, group, line_color = "auto", line_size = 1)
|
data |
Dataset used for the line chart |
x |
|
y |
|
group |
|
line_color |
|
line_size |
|
For plotting multiple lines line_chart()
can handle data in long or wide format.
If the data is in long format pass the variable that identifies individual lines
to the group
argument. If the data is in wide format pass a selection of variables
to the y
argument.
An object of class ggplot
Thomas Neitmann
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(dplyr, warn.conflicts = FALSE)
data("biomedicalrevenue")
data("revenue_wide")
line_chart(revenue_wide, year, Roche)
line_chart(revenue_wide, year, Roche, line_size = 1.5)
line_chart(revenue_wide, year, Roche, line_color = "darkorange")
## Plot multiple lines (data is in long format)
biomedicalrevenue %>%
filter(company %in% c("Roche", "Novartis", "Bayer")) %>%
line_chart(year, revenue, group = company)
## Plot multiple lines (data in wide format, i.e. one column per line)
## Select multiple columns with `c()`
line_chart(revenue_wide, year, c(Roche, Novartis, Bayer))
## Select all columns from Novartis to Sanofi suing `:`
line_chart(revenue_wide, year, Novartis:Sanofi)
## Select all columns starting with "B"
line_chart(revenue_wide, year, starts_with("B"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.