如何在R中的粘贴命令中的每个元素之间插入逗号?
如何在 R 中的粘贴命令中的每个元素之间插入逗号?
paste ("X",1:5,sep="")
"X1" "X2" "X3" "X4" "X5"
现在我想在每个元素之间插入逗号
Desired Output
"X1","X2","X3","X4","X5"
感谢您的帮助
How can I insert a comma between each element in paste command in R ?
paste ("X",1:5,sep="")
"X1" "X2" "X3" "X4" "X5"
Now I want to insert a comma between each element
Desired Output
"X1","X2","X3","X4","X5"
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为下面的两个命令之一应该适合您:
更新,基于注释:
不需要在向量元素“之间”放置逗号。您可以使用
paste
命令的输出作为read.table
的col.names
参数。I think one of the two commands below should work for you:
Update, based on comments:
There's no need to put commas "between" the vector elements. You can use the output of your
paste
command as thecol.names
arg toread.table
.