My question is motivated by dealing with pairs of values, like (3,12.5),  
(16,2.98), and so on
that are mapped to a cartesian plain (Time, Frequence) 
I miss C multidimensional arrays. I am trying to simulate the 3rd dimension by 
declaring a matrix of lists.
R seems to accept the definition of such a matrix. But I'm experiencing some 
difficulty at storing pairs of data
in it. In the following are some of my attempts.  
I would greatly appreciate some help. 

> A <- matrix(data ="list", nrow=2, ncol=4)
> A
     [,1]   [,2]   [,3]   [,4]  
[1,] "list" "list" "list" "list"
[2,] "list" "list" "list" "list"
> A[[1]] <- list(data="12.3",variable="d1")
Error in A[[1]] <- list(data = "12.3", variable = "d1") : 
  more elements supplied than there are to replace
> A[1,2] <- list(data="12.3",variable="d1")
Error in A[1, 2] <- list(data = "12.3", variable = "d1") : 
  number of items to replace is not a multiple of replacement length
> A[[1,2]] <- list(data="12.3",variable="d1")
Error in A[[1, 2]] <- list(data = "12.3", variable = "d1") : 
  more elements supplied than there are to replace
> A[[1,1]] <- list(data="12.3",variable="d1")
Error in A[[1, 1]] <- list(data = "12.3", variable = "d1") : 
  more elements supplied than there are to replace
> A[[1]][1] <- 10
> A[[1]][2] <- "f1-t1"
Error in A[[1]][2] <- "f1-t1" : 
  more elements supplied than there are to replace
> A[[1]][2] <- "d1"
Error in A[[1]][2] <- "d1" : 
  more elements supplied than there are to replace

Regards,
Maura










tutti i telefonini TIM!


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to