truncate_var_strings | R Documentation |
This function will truncate the strings in variables according to the length specified
truncate_var_strings(dt, var_name, trunc_length)
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 |
dataset with truncated variable
Stella Banjo(HackR 2021)
Reporting-related utility functions
convert_var_to_ascii()
,
create_R_script()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.