Teradata R Package Function Reference | 17.00 - 17.00 - summarise - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

Creates one or more columns summarising the columns of tbl_teradata. Tibbles with groups created by 'group_by()' and 'group_by_time()' will result in one or more rows in the output for each group based on the aggregate operation used in summarise. Tibbles without groups will result in one or more rows in the output based on the aggregate operation.

Usage

## S3 method for class 'tbl_teradata'
summarise(.data, ...)

Arguments

.data

Required Argument.
Specifies the tbl_teradata which contains the columns on which aggregate operations are to be performed.

...

Name-value pairs of summary functions. The name specifies the name of the column in the result tbl_teradata. The value specifies an expression that returns a single value like ‘min(x)', 'n()', or 'sum(is.na(y))' where ’x' and 'y' are the column names.

Value

A 'tbl_teradata' object.

See Also

summarise function in the dplyr package for some other examples of summarise.

Examples

# Get remote data source connection.
con <- td_get_context()$connection

# Load the required tables.
loadExampleData("time_series_example", "ocean_buoys_seq")

# Create object of class "tbl_teradata".
df_seq <- tbl(con, "ocean_buoys_seq")

# Example 1: Get the minimum of the column 'temperature', grouped by timebucket
#            timebucket duration of 30 minutes and the column 'buoyid'.

# Grouping by timebucket duration of 30 minutes and 'buoyid'.
seq_group1 <- df_seq %>% group_by_time(timebucket.duration = "30m",
                                       value.expression = "buoyid")

# Applying min() aggregation on grouped tbl object.
seq_group1 %>% summarise(min_temp = min(temperature))

# Example 2: Get the minimum of the column 'temperature' grouped by the
#            column 'buoyid'.

# Grouping by column 'buoyid'.
seq_group2 <- df_seq %>% group_by(buoyid)

# Applying min() aggregation on grouped tbl object.
seq_group2 %>% summarise(min_temp = min(temperature))