Difference between paste() and paste0()

前端 未结 3 1750
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 08:16

Being new to R, can someone please explain the difference between paste() and paste0(), what I had understood from some post is that

p         


        
3条回答
  •  鱼传尺愫
    2021-01-31 08:30

    Let me put it in a simple words.. paste0 will automatically exclude the space in your concatenation..

    For Example, I want to create a Training and test path..here's the code..

    > Curr_date=format(Sys.Date(),"%d-%b-%y")
    
    > currentTrainPath = paste("Train_",Curr_date,".RData")
    
    > currentTrainPath
    
    [1] "Train_ 11-Jun-16 .RData"
    
    > Curr_date=format(Sys.Date(),"%d-%b-%y")
    
    > currentTrainPath = paste0("Train_",Curr_date,".RData")
    
    > currentTrainPath
    
    [1] "Train_11-Jun-16.RData"
    

提交回复
热议问题