0

I have 6 matrices of size 100*50 (e.g. m1-m6) and 6 matrices of size 100*100 (m7-m12). these matrices are nested withing two factors as F and G. I want to create a data structure that reflects this design:

F1 G1 m1 F1 G2 m2 F1 G3 m3 F1 G1 m4 F1 G2 m5 F1 G3 m6 F2 G1 m7 F2 G2 m8 F2 G3 m9 F2 G1 m10 F2 G2 m11 F2 G3 m12 

I want to use these structure for ANOVA and plotting the results. Each matrix consists of values over 100 replications. The m1-m12 matrices are stored in csv files.So, I need to import the matrices and create the data structure.I tried array or list but I couldn't find an efficient and correct way for doing that.

Any idea?

1 Answer 1

1

You can use array, First I create data structure:

A1 = array(0,dim=c(100,50,6)) A2 = array(0,dim=c(100,100,6)) 

I assume you have 2 list of file names , list_files1 and list_files2:

lapply(seq_along(list_files1),function(x){ A1[,,x] <- read.csv(list_files1[[x]]) }) lapply(seq_along(list_files2),function(x){ A2[,,x] <- read.csv(list_files2[[x]]) }) 
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the solution.What do you mean by list file?How can I create it in R?Also, the A1 and A2 has to be combined containing factors.How could it be done?
@Amin I can if you add an example of the expected output. For example edit your question and add an example of the expected output , using 2 matrix of size 2*2 and 2*4.
I want to compare matrices based on the factors.In other words, each matrix has occurred under a specific condition defibed bt factors so factors are indicators of experiment's condition for each matrix.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.