My table k looks like:
我的表k是这样的:
rsID
rs6786
rs798
rs56,COSM787,COSM687
rs097,COSM96,COSM90,COSM76
I want to have following (I need the word before the first comma):
我想要跟随(在第一个逗号之前我需要这个词):
rsID
rs6786
rs798
rs56
rs097
I try to run this code but I have the error: "Error in !row.names : invalid argument type":
我尝试运行这段代码,但我有错误:“错误!行。名称:无效参数类型”:
UPDATE k
SET rsID = SUBSTRING(rsID, 1, CHARINDEX(',', rsID) - 1)
WHERE CHARINDEX(',', rsID) > 0
1 个解决方案
#1
1
We could use sub
我们可以使用子
df1$rsID <- sub(',.*', '', df1$rsID)
df1
# rsID
#1 rs6786
#2 rs798
#3 rs56
#4 rs097
data
df1 <- structure(list(rsID = c("rs6786", "rs798",
"rs56,COSM787,COSM687",
"rs097,COSM96,COSM90,COSM76")), .Names = "rsID",
class = "data.frame", row.names = c(NA, -4L))
#1
1
We could use sub
我们可以使用子
df1$rsID <- sub(',.*', '', df1$rsID)
df1
# rsID
#1 rs6786
#2 rs798
#3 rs56
#4 rs097
data
df1 <- structure(list(rsID = c("rs6786", "rs798",
"rs56,COSM787,COSM687",
"rs097,COSM96,COSM90,COSM76")), .Names = "rsID",
class = "data.frame", row.names = c(NA, -4L))