我的R档案里有很多这样的东西:
c(Johnny Bladel,Ball, Ball, Called Strike, 15 Johnny Bladel putout
(4-3) for out number 1)
我只是从网站上复制和粘贴这个,我需要在引号之间的任何东西上加上引号。如下所示:
c("Johnny Bladel","Ball", "Ball", "Called Strike", "15 Johnny Bladel putout(4-3) for out number 1")
Rstudio上有什么热键可以让我自动完成这个任务吗?
发布于 2016-05-14 05:57:28
我们可以在scan
文件的末尾删除c(
和)
。
v1 <- gsub("^c\\(|\\)$" , "", trimws(scan("yourfile.txt", what = "", sep=",", quiet=TRUE)))
dput(v1)
#c("Johnny Bladel", "Ball", "Ball", "Called Strike", "15 Johnny Bladel putout (4-3) for out number 1")
发布于 2016-05-14 05:38:10
不确定Rstudio中是否有这样的键,但您可以在vi编辑器中多个步骤编辑该文件。也许有一种更优雅的方法来做这件事,但这也应该是工作的一部分。
%s/^/"/g
%s/$/"/g
%s/,/","/g
%s/" /"/g
https://stackoverflow.com/questions/37222547
复制相似问题