【问题标题】:Convert an object into a string within a method in R在R中的方法中将对象转换为字符串
【发布时间】:2019-12-06 17:24:41
【问题描述】:

这很简单。

v = c("var1", "var2", "var3")

for (i in v) {
function(data = df, ..., main = "here comes a text and \v")
}

问题是,我怎样才能确保 v 出现在那里?我知道 Swift 有这个 \() 命令,你可以在字符串中传递它。

编辑 paste解决了这个问题。

【问题讨论】:

    标签: r string loops


    【解决方案1】:

    你在找paste()吗?

    v = c("var1", "var2", "var3")
    
    for (i in v) {
    function(data = df, ..., main = paste("here comes a text and",v))
    }
    

    这将使main 等于Here comes a text and var1Here comes a text and var2here comes a text and var3

    【讨论】:

    • 好的,知道了。谢谢!
    • 这将是一个关于函数本身代码的不同问题..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-04
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    相关资源
    最近更新 更多