Dictionaries and pairs

前端 未结 5 1985
时光取名叫无心
时光取名叫无心 2021-01-17 06:53

In R I was wondering if I could have a dictionary (in a sense like python) where I have a pair (i, j) as the key with a corresponding integer value. I have not

5条回答
  •  时光取名叫无心
    2021-01-17 07:12

    You can do this with a list of vectors.

    maps <- lapply(vector('list',5), function(i) integer(0))
    maps[[1]][2] <- 1
    maps[[1]][3] <- 3
    maps[[1]][4] <- 4
    maps[[1]][5] <- 3
    

    That said, there's probably a better way to do what you're trying to do, but you haven't given us enough background.

提交回复
热议问题