I would like to un-wrap the wrapped text in r. However, it is not successful after as.character().
Here is a toy code:
t<-c("The adds fundamental principle”, The discriminatory ")
str_wrap(t,3)
Indeed, I did have a look at the question here, but I am not sure what are {0,2}$ and .{3}. Not sure if they are helpful in solving my problem though.
Some more extreme cases might contain line breaks ("\n") or multiple spaces between the words/ at the end of the strings. For these cases, I acknowledge that str_wrap() might not be the best option to wrap the string. Any suggestion on how to wrap and unwrap the string is greatly appreciated. Below is another toy data:
example<-c("The extreme long long\nlonglong long. long long strings”, The theory is about. ")
str_wrap(example,3)
Might not get you fully back to exactly the same string but you can just paste it back together in this example:
It obviously here leaves off the space at the end of the string, but the wrapped string contains no data whatsoever about trailing white space in the original string. Also, if the original string did contain line breaks, the reverse step would be unable to distinguish this from wrap-inserted line break.