Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.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
替换dataframe中的部分变量字符串_R_Regex_String - Fatal编程技术网

替换dataframe中的部分变量字符串

替换dataframe中的部分变量字符串,r,regex,string,R,Regex,String,我有数据框: SINGLE_MEM crd 1 5 -97.75514500005232 30.263874000727306 2 8 -97.81095799930782 30.234157000528484))) 3 3 ((-97.68044500036247 30.267636999839592 4 2

我有数据框:

     SINGLE_MEM                     crd    
1          5        -97.75514500005232 30.263874000727306
2          8        -97.81095799930782 30.234157000528484))) 
3          3        ((-97.68044500036247 30.267636999839592 
4          2        -97.71808637589912 30.1848525102668))  
5         10        -97.76847799967814 30.432537999903005  
6          6        -97.6937453403672  30.46382579769979  
在crd列中,我有字符中的坐标。我需要替换所有的“()” 在一个缺口上。我将“)”、“)”、“)))”替换为

df$crd您可以使用

gsub("[()]+", "", df$crd)

试试
gsub(“[(]|[)]”,“,”(((())”)
@Jimbou哦,很管用,谢谢
gsub("[()]+", "", df$crd)