RoundColumns
Description
Function to round the values of each specified input tbl_teradata column to a
specified number of decimal places.
Usage
td_round_columns_sqle (
data = NULL,
target.columns = NULL,
precision.digit = 0,
accumulate = NULL,
...
)
Arguments
data |
Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata
|
target.columns |
Required Argument.
Specifies the name(s) of the column(s) in "data" to round every value to
precision digits.
Types: character OR vector of Strings (character)
|
precision.digit |
Optional Argument.
Specifies the number of decimal places to which to round values for
the "target.columns".
If positive, the function rounds values to the right of the decimal point.
If negative, the function rounds values to the left of the decimal point.
If not provided, the function rounds the column values to 0 places.
Note:
If the column values have the DECIMAL/NUMERIC data type with a precision less
than 38, then the function increases the precision by 1. For example, when a
DECIMAL (4,2) value of 99.99 is rounded to 0 places, the function returns a
DECIMAL (5,2) value, 100.00. However, if the precision is 38, then the function
only reduces the scale value by 1 unless the scale is 0. For example, the
function returns a DECIMAL (38, 36) value of 99.999999999 as a DECIMAL
(38, 35) value, 100.00.
Default Value: 0
Types: integer
|
accumulate |
Optional Argument.
Specifies the names of input tbl_teradata columns to copy to the output.
Types: character OR vector of Strings (character)
|
... |
Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:
persist:
Optional Argument.
Specifies whether to persist the results of the function in a table or not.
When set to TRUE, results are persisted in a table; otherwise, results
are garbage collected at the end of the session.
Default Value: FALSE
Types: logical
volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table or not.
When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical
Function allows the user to partition, hash, order or local order the input
data. These generic arguments are available for each argument that accepts
tbl_teradata as input and can be accessed as:
"<input.data.arg.name>.partition.column" accepts character OR vector of Strings (character) (Strings)
"<input.data.arg.name>.hash.column" accepts character OR vector of Strings (character) (Strings)
"<input.data.arg.name>.order.column" accepts character OR vector of Strings (character) (Strings)
"local.order.<input.data.arg.name>" accepts logical
Note:
These generic arguments are supported by tdplyr if the underlying
SQL Engine function supports, else an exception is raised.
|
Value
Function returns an object of class "td_round_columns_sqle"
which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator
using the name(s):result
Examples
# Get the current context/connection.
con <- td_get_context()$connection
# Load the example data.
loadExampleData("tdplyr_example", "titanic")
# Create tbl_teradata object.
titanic_data <- tbl(con, "titanic")
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1: Rounding "fare" column to 2 decimal places.
obj <- td_round_columns_sqle(
data=titanic_data,
target.columns="fare",
precision.digit=2,
accumulate=c('pclass', 'sex'))
# Print the result.
print(obj$result)