I am able to split a long string into 40 char columns using the following:
temp_df <- data.frame(
long_string_column = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Whatever ornare nunc tellus, nec convallis enim viverra sit amet."
)
library(tidyr)
temp_df_new <- separate(temp_df,
long_string_column,
into = c("split1", "split2", "split3", "split4", "split5"),
sep = c(40, 80, 120, 160),
remove = FALSE)
However this splits across words and can result in half the word being in one column and the other half being in the next.
Is there anyway to ensure that splitting across words doesn't occur?