很多时候一个功能,我发现自己键入以下R:使用省略号与需要的参数的任意数量
print(paste0(val1,',',val2,',',val3)) to print the output from a function with variables separated by a comma.
,当我要复制生成的输出csv文件这是很方便的。
我想知道如果我可以在R中编写一个函数来为我做这个。经过多次尝试,我只能得到以下结果。
ppc <- function(string1,string2,...) print(paste0(string1,',',string2,',',...,))
它适用于最多三个参数。
> ppc(1,2,3)
[1] "1,2,3"
> ppc(1,2,3,4)
[1] "1,2,34"
ppc(1,2,3,4)
应该给"1,2,3,4"
。我该如何纠正我的功能?我以某种方式认为这在R中是可能的。
意识到我不需要为此编写任何单独的函数。这是一个愚蠢的问题... –