1
我正在嘗試創建一個r循環來運行一系列數據集上的命令。命令是RMark
庫中的make.design.data
。它需要的唯一參數是列表的名稱。我有這些名單的17我想傳遞給make.design.data這是我一直在嘗試使用如何使用循環遍歷一組列表
DFNames<-c("DFAmerican.Goldfinch", "DFAmerican.Robin","DFBarn.Swallow","DFBobolink", "DFBrown.head.Cowbird", "DFCedar.Waxwing", "DFCommon.Grackle","DFCommon.Yellowthroat", "DFEuropean.Starling","DFHorned.Lark", "DFKilldeer","DFRed.wing.Blackbird", "DFSavannah.Sparrow", "DFSong.Sparrow","DFTree.Swallow", "DFVesper.Sparrow", "DFYellow.Warbler")
#in my environment each of the names given to DFNames represents a list
for (x in DFNames){
n<-make.design.data(x)
assign(paste0("ddl",x),n)
}
這給我的錯誤
Error in data$model : $ operator is invalid for atomic vectors
誰能代碼請建議一種方法來修復我的代碼,或者以不同的方式解決這個問題?
感謝,裘德
感謝您的快速回復。 lapply給了我與我原來的代碼相同的錯誤信息,但你建議的lopp工作得很好。 – user2030530