我从终端复制代码到这里发布。它的格式如下:
前两行是命令,而接下来的三行是输出结果。然而,由于命令是以"> "开始的,因此无法将其从此处复制回R终端。您应该如何转换为:
所以它变得适合从这里复制。
我尝试了:
但它无法粘贴到终端。
> ddf2 = ddf[ddf$stone_ny>'stone',] # this is first command
> ddf2[!duplicated(ddf2$deltnr),] # second command
deltnr us stone_ny stone_mobility
4 1536 63 stone mobile
10 1336 62 stone mobile
前两行是命令,而接下来的三行是输出结果。然而,由于命令是以"> "开始的,因此无法将其从此处复制回R终端。您应该如何转换为:
ddf2 = ddf[ddf$stone_ny>'stone',] # this is first command
ddf2[!duplicated(ddf2$deltnr),] # second command
# deltnr us stone_ny stone_mobility
#4 1536 63 stone mobile
#10 1336 62 stone mobile
所以它变得适合从这里复制。
我尝试了:
text
[1] "> ddf2 = ddf[ddf$stone_ny>'stone',] # this is first command\n> ddf2[!duplicated(ddf2$deltnr),] # second command\n deltnr us stone_ny stone_mobility \n4 1536 63 stone mobile \n10 1336 62 stone mobile "
text2 = gsub('\n','#',text)
text2 = gsub('#>','\n',text2)
text2 = gsub('#','\n#',text2)
text2
[1] "> ddf2 = ddf[ddf$stone_ny>'stone',] \n# this is first command\n
ddf2[!duplicated(ddf2$deltnr),] \n# second command\n# deltnr us stone_ny stone_mobility \n#4 1536 63 stone mobile \n#10 1336 62 stone mobile "
但它无法粘贴到终端。
Sublime Text 3
+Enhanced R package
(适用于ST3)。多行编辑功能非常强大。 - Ricardo Saporta>
标记一起复制到剪贴板中,然后在Rgui中选择“编辑”,然后选择“仅粘贴命令”。请注意,许多在SO上发布其代码的人会在输出行前面添加##
标记,并且不包括>
。 - G. Grothendieck