why there is a gap in the file name created using paste?

我的未来我决定 提交于 2019-12-02 23:38:16

问题


I was trying to write a file using R and in order to distinguish each file, i tried to add a different suffix each time in a function.

For example......

    counts <- function(counts_file)
    {
     ..............................
     ..............................
     name <- substr(counts_file,1,5)
     file <- paste(name,".cpm.csv")
     write.csv(countpermillion, file)
     }

But when i run the function counts("JKNC1.bam.tsv"), the output file created is like this
JKNE3 .cpm.csv i.e there is a gap between the JKNEE3 and .cpm.csv. What am i doing wrong here?

Thanks Upendra


回答1:


The default separator is a space. paste(name,".cpm.csv",sep="") should do what you want here. Alternately, you could use

paste0(name,".cpm.csv")

The documentation for this can be found by typing ?paste at the console.



来源:https://stackoverflow.com/questions/19171366/why-there-is-a-gap-in-the-file-name-created-using-paste

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!