dbplot_bar: Bar plot

Description Usage Arguments See Also Examples

View source: R/discrete.R

Description

Uses very generic dplyr code to aggregate data and then 'ggplot2' to create the plot. Because of this approach, the calculations automatically run inside the database if 'data' has a database or sparklyr connection. The 'class()' of such tables in R are: tbl_sql, tbl_dbi, tbl_spark

Usage

1
dbplot_bar(data, x, ..., y = n())

Arguments

data

A table (tbl)

x

A discrete variable

...

A set of named or unamed aggregations

y

The aggregation formula. Defaults to count (n)

See Also

dbplot_line , dbplot_histogram, dbplot_raster

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(ggplot2)
library(dplyr)

# Returns a plot of the row count per am
mtcars %>%
  dbplot_bar(am)

# Returns a plot of the average mpg per am
mtcars %>%
  dbplot_bar(am, mean(mpg))

# Returns the average and sum of mpg per am
mtcars %>%
  dbplot_bar(am, avg_mpg = mean(mpg), sum_mpg = sum(mpg))

edgararuiz/dbplot documentation built on Feb. 9, 2020, 10:21 p.m.