Alternative function to paste

前端 未结 5 1960
陌清茗
陌清茗 2021-02-04 03:43

Is there a function that can be an alternative to paste ? I would like to know if something like this exists in R:

> buildString ( \"Hi {1}, Have a very nice         


        
5条回答
  •  自闭症患者
    2021-02-04 04:04

    The sprintf function is one approach as others have mentioned, here is another approach using the gsubfn package:

    > library(gsubfn)
    > who <- "Tom"
    > time <- "day"
    > fn$paste("Hi $who, have a nice $time")
    [1] "Hi Tom, have a nice day"
    

提交回复
热议问题