我想改變我的一個R函數的輸出的名稱,以反映輸入不同的字符串。這是我曾嘗試:連接字符串,使變量名
kd = c("a","b","d","e","b")
test = function(kd){
return(list(assign(paste(kd,"burst",sep="_"),1:6)))
}
這只是一個簡單的測試功能。我得到警告(這是一樣糟糕的錯誤對我來說):
Warning message:
In assign(paste(kd, "burst", sep = "_"), 1:6) :
only the first element is used as variable name
理想情況下,我會得到像輸出中a_burst = 1,b_burst = 2,依此類推,但我不是越來越近。
我會用向量的內容,喜歡分裂出一個數據幀,並能夠根據從向量,相似的名字來命名的一切
How to split a data frame by rows, and then process the blocks?
但並不完全。命名是必要的。
正是我在找的東西。非常感謝你! – user1807096 2013-05-13 22:30:55