Francois.Bastardie at ifremer.fr
2006-Jun-16 15:50 UTC
[R] a method to trim composite objects?
dear R users, please, consider the following code you may run: setClass("my.class1", representation( my.list = "list", my.array1 = "array"), prototype=prototype( my.list =list(), my.array1 =array(0,c(3,3,3)) )) #------------------ setClass("my.class2", representation( my.array2 = "array", my.array3 = "array"), prototype=prototype( my.array2 =array(0,c(3,3,3)), my.array3 =array(0,c(3,3,3)) )) #------------------ x <- new("my.class1") x at my.list[[1]] <- new("my.class2") x at my.list[[2]] <- new("my.class2") Is there any method in R to trim dimensions of all the component arrays (my.array1, my.array2, my.array3, etc.) in one time inside all the hierarchical level of the composite object I named 'x'? in other words, if I want to keep only the 2nd dimension, I have to do: x at my.array1[,2,] x at my.list[[1]]@my.array2[,2,] x at my.list[[1]]@my.array3[,2,] x at my.list[[2]]@my.array2[,2,] x at my.list[[2]]@my.array3[,2,] etc. thank you -- -------------------------------------------------------- Fran?ois Bastardie French Research Institute for the Development of the Sea (IFREMER) Ecologie et Mod?les pour l'Halieutique Rue de l'Ile d'Yeu BP 21105 44311 NANTES Cedex 03 - France T?l : 02 40 37 41 64 Fax : 02 40 37 40 75 E-mail : francois.bastardie at ifremer.fr