Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.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
Mysql 使用R处理向量值_Mysql_R_Vector - Fatal编程技术网

Mysql 使用R处理向量值

Mysql 使用R处理向量值,mysql,r,vector,Mysql,R,Vector,我需要帮助来操作向量值 listID <- c(to_del$UnitCode_correct) print(paste("Update unit set isDeleted=1 where UnitId in(",paste("'",listID,"'", collapse = " ,"),paste(")"))) 现在我需要从每个ID中删除这些额外的空格,例如-'SOD0390306','SOD0370274'应该与'SOD0390306','SOD0370274'类似 我尽力去做,

我需要帮助来操作向量值

listID <- c(to_del$UnitCode_correct)
print(paste("Update unit set isDeleted=1 where UnitId in(",paste("'",listID,"'", collapse = " ,"),paste(")")))
现在我需要从每个ID中删除这些额外的空格,例如-'SOD0390306','SOD0370274'应该与'SOD0390306','SOD0370274'类似


我尽力去做,但没能解决这个问题。另外,如果还有其他方法,请告诉我。

在粘贴中使用sep=和collapse=,如下代码所示:

listID <- c('SOD0390306','SOD0370274','SOD0370275','SOD0370276','SOD0370277','SOD0410257','SOD0410256','SOD0410255','SOD0410258','SOD0240282','SOD0420517')
print(paste("Update unit set isDeleted=1 where UnitId in (",paste("'",listID,"'", collapse = ",", sep=""),paste(")"), sep=""))
希望这有帮助。

使用paste0或Pastetralala,sep=。是的,代码中缺少sep=。只需要澄清一下,在代码中粘贴0或添加sep=参数的最佳方法是什么?
listID <- c('SOD0390306','SOD0370274','SOD0370275','SOD0370276','SOD0370277','SOD0410257','SOD0410256','SOD0410255','SOD0410258','SOD0240282','SOD0420517')
print(paste("Update unit set isDeleted=1 where UnitId in (",paste("'",listID,"'", collapse = ",", sep=""),paste(")"), sep=""))
"Update unit set isDeleted=1 where UnitId in ('SOD0390306','SOD0370274','SOD0370275','SOD0370276','SOD0370277','SOD0410257','SOD0410256','SOD0410255','SOD0410258','SOD0240282','SOD0420517')"