Ng Stanley
2008-Apr-16 00:36 UTC
[R] How to get assign an vector of words to associative array ?
Hi, How to get assign an vector of words to associative array ?> a[["animal"]] <- c("dog", "cat")Error in a[["animal"]] <- c("dog", "cat") : more elements supplied than there are to replace Thanks stanley [[alternative HTML version deleted]]
Duncan Murdoch
2008-Apr-16 00:46 UTC
[R] How to get assign an vector of words to associative array ?
On 15/04/2008 8:36 PM, Ng Stanley wrote:> Hi, > > How to get assign an vector of words to associative array ? > >> a[["animal"]] <- c("dog", "cat") > Error in a[["animal"]] <- c("dog", "cat") : > more elements supplied than there are to replaceR uses named lists as associative arrays, but the line above is not enough to create one. You need a <- list() a[["animal"]] <- c("dog", "cat") The error message you saw is probably because "a" already existed, and wasn't a list. Duncan Murdoch