I have many text files in which I want to load them all and then make a new matrix with a certain columns from all files
for example some matrices are as follows:
1a <- replicate(10, rnorm(20))
1b <- replicate(10, rnorm(19))
2a <- replicate(10, rnorm(18))
2b <- replicate(10, rnorm(15))
how I reconize them, I put them all in a folder and I set my directory there then I can get the list of them like
filelist = list.files(pattern = ".*.txt")
Then I want to put the first column of the 1a and V6 and V7 in a new matrix then I want to put the V6 and V7 from the 1b in a new matrix then I want to put the V6 and V7 from the 2a in a new matrix then I want to put the V6 and V7 from the 2b in a new matrix
The files are not in the same length (their rows are different from each other) . I would like to do two things
1- save the same file with selected columns with an added R to the name for example if the original file is 1a, then select V6 and V7 and same a new file with only 2 columns and name 1aR
2- make a new matrix and put all the selected columns in that (those that are not equal , we can make NA or 0 there