0

いくつかのデータ:

reslist <- list()
reslist <- append(reslist,list(c(1,2,3,4)))
names(reslist) <- "name1"
reslist <- append(reslist,list(c(3,4,1,0)))

リストの最後の要素だけに名前を付けるにはどうすればよいですか?私の実際のリストは可変長なので、最後の要素のインデックスがわかりません。

names(reslist[[length(reslist)]]) <- "name2"

名(names(reslist)<-"name1")として機能しないのはなぜですか?

4

1 に答える 1

4

間違ったものをインデックスに登録しているだけです。これを試して:

names(reslist)[length(reslist)] <- 'name2'
于 2013-01-17T14:53:35.047 に答える