R语言字符串处理函数—strwrap

Each character string in the input is first split into paragraphs (or lines containing whitespace only). The paragraphs are then formatted by breaking lines at word boundaries. The target columns for wrapping lines and the indentation of the first and all subsequent lines of a paragraph can be controlled independently.

strwrap(x, width = 0.9 * getOption("width"), indent = 0,exdent = 0, prefix = "", simplify = TRUE, initial = prefix)
每一个输入的字符串都是被当做一个段落(或者仅包含空格的行)。段落按照设置的格式(width,indent,exdent)进行分行。每一行为一个字符串作为结果返回。

width参数指定每一行的宽度

indent指定段落首行的缩进

exdent指定除首行之外的行缩进方式

prefix:是一个字符串。用于作为段落中首行除外的行的前缀

simplify :逻辑变量。默认为TRUE。此时结果是一个单个的行文本的字符向量 ;当值为False时,结果是一个和x同样长度的list,list每一个元素是单个的行文本的字符向量。(其实前者就是不把结果存在list中的结果)。

猜你喜欢

转载自blog.csdn.net/intelligebce/article/details/81167383