line_chart: Line Chart

Description Usage Arguments Details Value Author(s) Examples

View source: R/line_chart.R

Description

Easily create a line chart

Usage

1
line_chart(data, x, y, group, line_color = "auto", line_size = 1)

Arguments

data

Dataset used for the line chart

x

numeric column of data

y

numeric column of data or a tdiyselect expression

group

character or factor column of data defining individual lines

line_color

character. Line color

line_size

character Line width in mm

Details

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.

Value

An object of class ggplot

Author(s)

Thomas Neitmann

Examples

 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"))

thomas-neitmann/ggcharts documentation built on Oct. 8, 2021, 1:17 a.m.