[R] rbind to array members

Another Oneforyou anotheroneforyou at hotmail.com
Mon Oct 19 01:27:09 CEST 2009


Hi,
I would like to add rows to arbitrary tables within a 3dimensional array.
I can directly add data to an existing row of a table:
> x <- array(0,c(1,3,2))> x[,,1] <- c(1,2,3)
And I can even add a row to the table and assign to another object.
> y <- rbind(x[,,1], c(4,5,6))
and 'y' is what I want it to be:> y     [,1] [,2] [,3][1,]    1    2   3[2,]    4    5   6
but I can't do this within the 3dimensional array:
> x[,,1] <- rbind(x[,,1], c(4,5,6))Error in x[, , 1] <- rbind(x[, , 1], c(4, 5, 6)) :   number of items to replace is not a multiple of replacement length
Does anyone know I can add rows to one of tables within the array?
Thanks.

 		 	   		  
_________________________________________________________________
Hotmail: Free, trusted and rich email service.




More information about the R-help mailing list