I have several files with the same name: data.out and they are in different folders.
I need to get some data on each of these files, save them in file (.csv) to then open in R later. The data that I will need in each of these files are matrices of 7x7. like that:
***** Estimates of covariance matrix ***************************************
Matrix
1 0.8
2 5.6 0.2
3 3.6 5.1 1.3
4 1.2 6.6 1.2 5.6
5 2.7 -3.2 -8.6 3.1 7.2
6 5.1 9.3 5.8 2.4 4.2 6.2
7 1.5 -2.6 -3.1 9.2 8.1 8.7
1.1
**** Estimates of residual matrix ***********************************
Covariance matrix
1 2.1
2 4.1 3.1
3 1.3 5.6 1.4
4 4.5 2.1 8.5 1.1
5 5.1 -5.1 -6.6 5.2 4.1
6 2.4 4.7 4.2 3.1 -1.2 1.7
7 1.2 9.2 3.1 4.5 8.1 1.3
3.9
**** Estimates of correlation matrix ***********************************
Correlation matrix
1 1
2 4.1 1
3 1.3 5.6 1
4 4.5 2.1 8.5 1
5 5.1 -5.1 -6.6 5.2 1
6 2.4 4.7 4.2 3.1 -1.2 1
7 1.2 9.2 3.1 4.5 8.1 1.3
3.9
I was wondering if vim can help me to do what I would like to but can't figure it out. I first thought to use line number as an index but they are not the same in each file. In short, I want to get these matrices from each file (data.out) in each directory (different names). Then, save them as .csv files to open in R.
Is that I way to do that without being copy and paste manually? Is vim or other text editor or even R can help me to do this faster? thanks
CodePudding user response:
I'm not sure this is what you are looking for, but you can append to a register by using uppercase letters. example:
- in the first file, visually select the desired text. Copy to register 'a':
"ay
- in the following files, visually select the desired text. Append to the same register:
"Ay
- in the destination file, paste from said register:
"ap
You can also copy/append the other ways you know from Vim. E.g.: Append the following 5 lines to register 'a': 4"Ayj
, or append from within braces to register 'a': "Ayi}