基于空格分隔符按200字符长度拆分文本的R语言实现需求
按分隔符与固定长度拆分文本(R语言实现)
需求:基于指定分隔符(本示例为空格),按照固定长度(200字符)拆分文本,从数据框的text变量生成col、col1、col2三列。
以下是示例代码与数据:
df <- data.frame(id=1,text='The INDEXC function searches source from left to right, for the first occurrence of any character present in the excerpts and returns the position in source of that character. If none of the characters in excerpt-1 through excerpt-n in source are found, INDEXC returns a value of 0. The REVERSE function creates backward writing, such that the last character in the argument becomes the first character in the result, the next-to-last character in the argument becomes the second character in the result, and so on. Below macro combines INDEXC/REVERSE function to automatically derive COVAL-COVALn based on comment’s length.', col='The INDEXC function searches source from left to right, for the first occurrence of any character present in the excerpts and returns the position in source of that character. If none of the characters in excerpt-1 through excerpt-n ', col1='in source are found, INDEXC returns a value of 0. The REVERSE function creates backward writing, such that the last character in the argument becomes the first character in the result, the next-to-last character in the argument becomes', col2='the second character in the result, and so on. Below macro combines INDEXC/REVERSE function to automatically derive COVAL-COVALn based on comment’s length.')
内容的提问来源于stack exchange,提问作者jkatam
相关产品推荐
相关产品推荐

