# Basic usage with a data.frame
df <- data.frame(
numbers = 1:3,
letters = c("a", "b", "c")
)
str_output <- tableToString(df)
cat(str_output)
# Using in error messages
df <- data.frame(value = c(10, 20, 30))
if (any(df$value > 25)) {
msg <- sprintf(
"Values exceed threshold:\n%s",
tableToString(df)
)
message(msg)
}
Run the code above in your browser using DataLab