拆分字符串固定宽度

时间:2016-04-26 18:19:20

标签: r string split splitstackshape

对于这个肯定基本的问题感到抱歉,但我真的找不到明确的答案:

我有一个数据框我试图按固定数量的字符分割

我以前一直在使用:

data = cSplit(data, 'variable', sep="what to separate on", type.convert=FALSE)

...要拆分,但是如果有多个"要拆分的内容"在数据中。

我想将这个名字列拆分为前四个字符(分拆为"。"导致多个&#34的名称出现问题;。"

names
Mr. Joe Smith
Ms. Sarah A. Jones
Mr. Ryan P. Young
Ms. Chelsea White

数据

names <- c('Mr. Joe Smith', 'Ms. Sarah A. Jones', 'Mr. Ryan P. Young', 'Ms. Chelsea White')

0 个答案:

没有答案