[英]How to adjust text width in R?
Is there a function that does this?有这样的 function 吗?
input:输入:
text <- "I have a little dog"
desired output:所需的 output:
some_function(text, max_width = 8)
#output: "I have a\nlittle dog"
some_function(text, max_width = 15)
#output: "I have a little\ndog"
stringr::str_wrap
does this: stringr::str_wrap
这样做:
text <- "I have a little dog"
stringr::str_wrap(text, 15)
#[1] "I have a little\ndog"
Output may vary in certain cases because of the underlying algorithm it uses. Output 在某些情况下可能会有所不同,因为它使用的底层算法。
stringr::str_wrap(text, 8)
[1] "I have\na little\ndog"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.