truncate_var_strings {sdtmchecks}R Documentation

Utility function to truncate data in var_name

Description

This function will truncate the strings in variables according to the length specified

Usage

truncate_var_strings(dt, var_name, trunc_length)

Arguments

dt

dataset e.g. AE

var_name

variable name e.g. AETERM

trunc_length

e.g. length the string will be truncated to e.g. 50

Value

dataset with truncated variable

Author(s)

Stella Banjo(HackR 2021)

See Also

Reporting-related utility functions convert_var_to_ascii(), create_R_script()

Examples


# Testing: no truncation

AE <- data.frame(
 USUBJID = 1:5,
 DOMAIN = "AE",
 AESEQ = 1:5,
 AESTDTC = 1:5,
 AETERM = 1:5,
 AEDECOD = 1:5,
 stringsAsFactors = FALSE
)

truncate_var_strings(AE, var_name = "AETERM", trunc_length = 50)

# Testing: Truncation

AE$AETERM[4] <- "THIS IS A SUPER LONG AE TERM, SO LONG IN FACT THAT ITS OVER 50 CHARACTERS."
AE$AETERM[5] <- "THIS AE TERM IS WAY TOO LONG FOR A NICELY FORMATTED REPORT"

truncate_var_strings(AE, var_name = "AETERM", trunc_length = 50)


[Package sdtmchecks version 1.0.0 Index]