Hey Mr Lawrence,
Your script works perfectly with the toy of data set but when I try to use it with my real data it does not work so well. My data consists of 174 individuals. Each individuals has two lines and in each line these are 120693 SNPs:
>h<- read.table("imputed_final.stru", sep="\t")
> m<-as.matrix(h)
> a <- aperm(array(m, c(2L, nrow(m)/2L, ncol(m))), c(1L, 3L, 2L))
> m2 <- matrix(a, dim(a)[3L], byrow=TRUE)
> View(m2)
It gives me one line for each individual but they are seprated like this:
Ind1_1 T C G C T Ind1_2 T C G C T
Ind2_1 T C G C T Ind2_2 T C G C T
Ind3_1 T C G C T Ind3_2 T C G C T
not like in the toy
> m3 <- matrix(a, dim(a)[3L], byrow=TRUE)
> m3
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] "A" "a" "B" "b" "C" "c" "D" "d"
[2,] "E" "e" "F" "f" "G" "g" "H" "h"
[3,] "J" "j" "K" "k" "L" "l" "M" "m"
Note: It works without any error or warrning messages with my real data but at the end it does not give me the rquired format.
Thanks and I am really appreciated to your help.
Best
Given the initial 6x4 matrix, do you want a 3x4 or a 3x8 matrix output? That's rather ambiguous from your presentation. I assume you want the latter, but perhaps not.