Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在字符中插入分隔符(逗号)?_R_String_Paste_Cat - Fatal编程技术网

R 如何在字符中插入分隔符(逗号)?

R 如何在字符中插入分隔符(逗号)?,r,string,paste,cat,R,String,Paste,Cat,如何更改@ManuelaSchwesig@sigmargabriel@nahles使用R?我们可以尝试通过在小写字母和@字符的连接处拆分来创建字符串的向量,从而使用正则表达式查找。在这里,strsplit的模式是一个积极的正则表达式查找((?请参见?strsplit)++ve要获得好的代码,请您也解释一下代码,我将不胜感激。@RavinderSingh13谢谢,我更新了一些解释。希望它有帮助。有关更多正则表达式信息,请查看 strsplit(str1, "(?<=[a-z])(?=@)",

如何更改
@ManuelaSchwesig@sigmargabriel@nahles
使用R?

我们可以尝试通过在小写字母和@字符的连接处拆分来创建字符串的
向量,从而使用正则表达式查找。在这里,
strsplit
的模式是一个积极的正则表达式查找(
(?请参见
?strsplit
)++ve要获得好的代码,请您也解释一下代码,我将不胜感激。@RavinderSingh13谢谢,我更新了一些解释。希望它有帮助。有关更多正则表达式信息,请查看
strsplit(str1, "(?<=[a-z])(?=@)", perl = TRUE)[[1]]
#[1] "@ManuelaSchwesig" "@sigmargabriel"   "@nahles" 
gsub("([a-z])@", "\\1,@", str1)
#[1] "@ManuelaSchwesig,@sigmargabriel,@nahles"
str1 <-  "@ManuelaSchwesig@sigmargabriel@nahles"