Home > database >  Rename elements with 0 to NA inside list of lists
Rename elements with 0 to NA inside list of lists

Time:08-26

I want to rename elements with value 0 to NA which lie within lists of lists. I want to do it for to the first four columns that lie within the lists (VA01.000252, VA01.000306, ...) of my main list (F_10). I have an approach which works for my test data but this approach already takes much time to process. The actual dataset is far bigger and I am worried it will take ages for the command to process. The test data and my approach both can be found below.

This is my data:

$VA01.000252
   VA01_F0finEnv VA01_F0final VA01_Jitter VA01_Shimmer VA01_MFCC.0.  VA01_MFCC.1.  VA01_MFCC.2.  VA01_MFCC.3.  VA01_MFCC.4.  VA01_MFCC.5.  VA01_MFCC.6.  VA01_MFCC.7.  VA01_MFCC.8.  VA01_MFCC.9. VA01_MFCC.10.
1        0.00000       0.0000           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
2        0.00000       0.0000           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
3        0.00000       0.0000           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
4       59.81091       0.0000           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
5      112.72920     138.0768           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
6      165.64740     138.0768           0    0.0000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
7      156.10650       0.0000           0    0.0000000   -129.11450 -4.886806e 00  8.293210e-01 -9.716904e-01  1.874519e 00 -3.330100e 00  1.155394e-01 -2.982753e-01  1.236686e 00  2.213515e 00 -1.102626e 00
8      151.33920     126.1790           0    1.0000000   -116.44960 -1.273737e 01  3.589834e-01 -4.425217e 00  9.199393e-01 -6.688267e 00 -1.412614e 00 -5.138365e 00 -1.940008e 00 -7.340010e-01 -1.923529e 00
9      154.11870     162.4571           0    0.7356322   -100.07050 -2.011970e 01  2.068043e-01 -6.162563e 00 -2.650808e-01 -9.938509e 00 -5.045537e 00 -8.725165e 00 -2.300158e 00 -1.821709e-01 -4.456659e 00
10     159.54650     180.1982           1    0.6034483    -85.24709 -2.219019e 01 -1.302721e 00 -6.597542e 00  2.171658e-01 -6.894450e 00 -1.055527e 01 -9.126151e 00 -1.717053e 00 -3.730820e 00 -1.023192e 01
11     167.09320       0.0000           0    0.0000000    -80.85322 -2.203539e 01  8.542528e-01 -3.835218e 00  4.422236e 00 -3.171251e 00 -1.415027e 01 -7.171879e 00  1.465298e 00 -2.147878e 00 -1.295104e 01
12     167.09320       0.0000           0    0.0000000    -81.12218 -2.372173e 01  1.530055e 00 -3.164595e 00  6.954316e 00 -2.101640e 00 -1.380905e 01 -2.736499e 00  2.313805e 00 -4.345511e 00 -1.015212e 01
13     167.09320       0.0000           0    0.0000000    -83.30384 -2.619328e 01  2.223715e 00 -1.346338e 00  6.163294e 00 -2.007305e 00 -1.238243e 01 -5.069185e 00 -1.514774e 00 -5.590108e 00 -4.327339e-01
14     167.09320       0.0000           0    0.0000000    -84.06513 -2.743844e 01  8.034258e-01 -8.133652e-01  3.687939e 00 -2.823765e 00 -8.803297e 00 -1.059612e 00 -2.296476e 00 -8.613113e 00  5.305792e 00
15     167.09320       0.0000           0    0.0000000    -83.64664 -2.706799e 01  1.158314e 00 -5.528085e-01  1.531354e 00 -2.680211e 00 -8.055579e 00 -2.319103e 00 -4.283731e 00 -8.192851e 00  7.707067e 00
16     167.09320       0.0000           0    0.0000000    -83.04565 -2.593493e 01  1.763077e 00 -3.936937e 00 -3.647466e 00 -6.354158e 00 -8.138985e 00  5.811316e-01 -2.851794e 00 -6.887127e 00  6.254632e 00
17     167.09320       0.0000           0    0.0000000    -82.64518 -2.568779e 01  1.347809e 00 -8.193944e 00 -5.826789e 00 -7.205881e 00 -1.052378e 01  1.576325e 00 -1.645603e 00 -3.474594e 00  6.372686e 00
18     167.09320       0.0000           0    0.0000000    -82.07550 -2.690814e 01 -1.296210e 00 -1.040748e 01 -6.379502e 00 -7.877069e 00 -1.063956e 01 -1.252872e 00 -2.972258e 00 -2.370217e 00  5.093191e 00
19     167.09320       0.0000           0    0.0000000    -81.27705 -2.732649e 01 -3.065270e 00 -7.066913e 00 -2.598729e 00 -5.304600e 00 -1.107656e 01 -3.846291e 00 -2.725531e 00 -1.543451e 00  3.412861e 00
20     167.09320       0.0000           0    0.0000000    -80.36498 -2.759527e 01 -3.365986e 00 -2.185576e 00 -8.248324e-01 -4.939477e 00 -9.010359e 00 -8.932830e 00 -4.472707e-01 -8.970172e-01 -4.256793e 00
21     167.09320       0.0000           0    0.0000000    -80.53387 -2.746712e 01 -1.673572e 00  1.303288e 00  1.375768e 00 -3.681439e 00 -1.134807e 01 -1.244722e 01  2.112881e 00 -2.435152e-02 -6.124821e 00
22     167.09320       0.0000           0    0.0000000    -81.29316 -2.871439e 01 -1.314733e 00 -1.031087e 00 -2.735091e 00 -5.713663e 00 -1.199027e 01 -1.460559e 01 -1.527567e 00  1.668803e-01 -6.425414e 00
23     167.09320       0.0000           0    0.0000000    -81.90575 -2.933984e 01 -2.327192e 00 -3.482757e 00 -5.539301e 00 -8.520871e 00 -1.524773e 01 -1.433087e 01 -5.164460e 00 -1.778122e 00 -5.645791e 00
24     167.09320       0.0000           0    0.0000000    -82.04091 -2.911803e 01 -3.437798e 00 -5.882364e 00 -7.277412e 00 -7.221782e 00 -1.225192e 01 -1.117920e 01 -7.191702e 00 -4.617439e 00 -6.148396e 00
25     167.09320       0.0000           0    0.0000000    -82.13178 -2.898966e 01 -4.838960e 00 -5.939596e 00 -4.656537e 00 -5.475117e 00 -8.213964e 00 -8.253125e 00 -5.136382e 00 -3.632409e 00 -5.178719e 00
26     167.09320       0.0000           0    0.0000000    -82.75354 -2.892703e 01 -4.283483e 00 -4.956952e 00 -8.748829e-01 -9.806442e-02 -3.997231e 00 -7.371384e 00 -5.868333e 00 -2.999556e 00 -8.084539e-01
27     167.09320       0.0000           0    0.0000000    -82.74642 -2.865274e 01 -3.706652e 00 -5.547077e 00 -5.480065e-01 -2.597058e 00 -6.388766e 00 -6.570017e 00 -5.618668e 00 -1.574020e 00  4.895750e-01
28     167.09320       0.0000           0    0.0000000    -83.49352 -2.922196e 01 -2.170068e 00 -2.311250e 00  3.320872e 00 -1.060383e 00 -7.007614e 00 -5.806552e 00 -1.797331e 00 -3.936761e 00 -2.398118e 00
29     167.09320       0.0000           0    0.0000000    -83.00410 -2.950762e 01 -2.355202e 00 -3.050338e 00  1.869767e 00 -2.100468e 00 -8.660001e 00 -1.047368e 01 -6.588408e 00 -8.047549e 00 -6.600111e 00
30     167.09320       0.0000           0    0.0000000    -83.05898 -3.081953e 01 -3.816830e 00 -2.152992e 00  4.679519e 00  5.164295e-01 -5.140864e 00 -1.107932e 01 -7.775589e 00 -5.094333e 00 -6.355783e 00
31     167.09320       0.0000           0    0.0000000    -82.02769 -3.005491e 01 -5.036798e 00 -6.075222e 00  3.737306e 00 -1.093793e 00 -8.630654e 00 -1.332389e 01 -1.209293e 01 -3.569095e 00 -5.040240e 00
32     167.09320       0.0000           0    0.0000000    -81.43015 -2.970782e 01 -5.878477e 00 -7.077900e 00  3.712163e 00 -3.901497e 00 -1.111143e 01 -1.353048e 01 -9.729337e 00 -4.175434e-01 -2.635696e 00
33     167.09320       0.0000           0    0.0000000    -80.90739 -2.939053e 01 -6.025192e 00 -9.395978e 00 -1.277639e 00 -9.709239e 00 -1.362978e 01 -1.536083e 01 -1.176102e 01 -8.894852e 00 -7.310049e 00
34     167.09320       0.0000           0    0.0000000    -80.45148 -2.961173e 01 -6.865067e 00 -1.135724e 01 -6.189119e 00 -1.109089e 01 -6.817587e 00 -1.570327e 01 -1.764861e 01 -1.836790e 01 -1.024871e 01
35     167.09320       0.0000           0    0.0000000    -80.31771 -2.975894e 01 -8.124461e 00 -1.445113e 01 -8.836887e 00 -8.614040e 00  1.459559e-01 -9.877742e 00 -1.786876e 01 -1.989631e 01 -1.123060e 01
   VA01_MFCC.11. VA01_MFCC.12. VA01_MFCC.13. VA01_MFCC.14.  VA01_LPCC.0.  VA01_LPCC.1.  VA01_LPCC.2.  VA01_LPCC.3.  VA01_LPCC.4.  VA01_LPCC.5.  VA01_LPCC.6. VA01_LPCC.7.          ID
1      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.000000e 00  0.0000000000  0.000000000 VA01.000252
2      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.000000e 00  0.0000000000  0.000000000 VA01.000252
3      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.000000e 00  0.0000000000  0.000000000 VA01.000252
4      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.0000000000  0.000000e 00  0.0000000000  0.000000000 VA01.000252
5      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0007353425  0.0133470400  0.0178267000  0.0236341200  0.0051963800 -1.534662e-02 -0.0123545200 -0.006236935 VA01.000252
6      0.0000000 -2.515524e-05     0.0000000    0.00000000  0.0039662060  0.0191080900  0.0221010400  0.0278217900 -0.0151209800 -4.988735e-02 -0.0621331400 -0.042875290 VA01.000252
7     -2.0578450 -4.526057e-01     2.1649830    1.14272200  0.0082406700  0.0184099100  0.0184085100  0.0133602000 -0.0395623400 -8.628076e-02 -0.1246156000 -0.076643490 VA01.000252
8     -1.1773900 -4.042094e 00     0.6001247    2.02709300  0.0089936970 -0.0018600400 -0.0103975200 -0.0467316300 -0.0761350200 -1.033836e-01 -0.1733676000 -0.094520330 VA01.000252
9     -0.3716143 -3.261007e 00    -2.8978200    1.42560600 -0.0011875660 -0.0181171800 -0.0357011600 -0.0943858200 -0.0780721500 -7.972527e-02 -0.1528078000 -0.058934500 VA01.000252
10    -5.6593810 -6.127711e 00    -9.1781060   -3.30674300 -0.0083277100 -0.0124441300 -0.0290099300 -0.0814918100 -0.0502561700 -4.298887e-02 -0.0858175000 -0.005338144 VA01.000252
11   -13.6049000 -8.965543e 00   -12.4168800   -6.97922100 -0.0075976880  0.0003679216 -0.0165640700 -0.0374678100 -0.0212830000 -1.222754e-02 -0.0205598000  0.020251940 VA01.000252
12   -13.6518400 -1.079708e 01    -8.1353630   -5.36020900  0.0086924730  0.0162289300  0.0083109860  0.0179146200  0.0030251260  3.650904e-04  0.0101194900  0.013467260 VA01.000252
13    -4.2140520 -6.399786e 00    -6.8131010   -3.99737200  0.0206394700  0.0124061600  0.0113651500  0.0281120900  0.0009592533 -7.675886e-05  0.0042102340 -0.010332560 VA01.000252
14     1.7268340  1.019973e 00    -5.8971240   -3.67270800  0.0160420600 -0.0025150540  0.0035499690  0.0217870700  0.0012038830 -6.543517e-04 -0.0064042090 -0.027503590 VA01.000252
15    -0.4274078 -1.942096e-01    -6.9390640   -7.73466900  0.0060903790 -0.0193745400 -0.0085384600  0.0069389700 -0.0046961070 -6.010354e-03 -0.0136247200 -0.039329630 VA01.000252
16    -3.1817960 -2.342408e 00    -4.2083140   -7.25781300  0.0024127930 -0.0237320200 -0.0180253000 -0.0007227779 -0.0012942670 -9.491324e-03  0.0037402510 -0.027839280 VA01.000252
17    -4.1359790 -2.151227e 00    -0.3981749   -5.82635500  0.0061842200 -0.0104811700 -0.0159853200 -0.0094374770 -0.0019166110 -1.936967e-02  0.0120926000 -0.049282360 VA01.000252
18    -5.1128360 -1.868084e 00     1.6251510   -2.92386500  0.0047843750  0.0127103400 -0.0049924250 -0.0127612000  0.0014022110 -1.778158e-02  0.0182165600 -0.060821820 VA01.000252
19    -4.6665450 -6.998692e-01     2.9522980   -0.91227390 -0.0067994530  0.0241639500 -0.0035714270 -0.0227305900 -0.0051709650 -1.781380e-02 -0.0107371700 -0.119747700 VA01.000252
20    -1.4622320 -1.024292e 00     6.0916290   -0.68188170 -0.0131211300  0.0206917000 -0.0007370055 -0.0167987500  0.0027669190 -3.750491e-03 -0.0177633900 -0.085645620 VA01.000252
21    -3.2021130 -1.547664e 00     5.2626800   -3.04651800 -0.0059770220  0.0106918900  0.0029697720 -0.0027474640  0.0168087400  6.712651e-03 -0.0074782970  0.011661980 VA01.000252
22    -5.5350250 -1.421402e 00     6.2528610   -5.16527700  0.0056278920 -0.0006325186  0.0064281520  0.0123923700  0.0251277800  1.237495e-02  0.0093992230  0.084718790 VA01.000252
23    -9.9739800 -4.194067e 00     2.7173540   -7.12243300  0.0191741000 -0.0036595940  0.0118473100  0.0195928100  0.0227896900  1.808438e-02  0.0132741000  0.112429100 VA01.000252
24    -7.4694330 -1.708854e 00    -0.9246085   -5.74657400  0.0205290900 -0.0010454420  0.0029362680  0.0147718700  0.0056231740  9.797978e-03  0.0017608400  0.045768830 VA01.000252
25    -4.6853820 -8.716103e-01    -3.6994880   -5.88591400  0.0133582600 -0.0026394610 -0.0060674670  0.0055232170 -0.0078798890 -4.472899e-03 -0.0002278447 -0.006507802 VA01.000252
26    -3.9408350  1.069726e 00    -0.3268897   -4.82812300 -0.0035384920  0.0003950119 -0.0101032000 -0.0074809790 -0.0234347300 -1.949897e-02 -0.0054683810 -0.056227680 VA01.000252
27    -0.7509457  2.139219e 00     6.6879060   -1.82945600 -0.0210549600 -0.0055490140 -0.0127789600 -0.0154033500 -0.0296738700 -1.992862e-02 -0.0132879900 -0.100097000 VA01.000252
28    -2.8119180 -2.486559e 00     3.3848200    0.40004780 -0.0158421100  0.0014721570 -0.0050028440 -0.0106496000 -0.0236421900  1.363218e-03 -0.0263921100 -0.087092330 VA01.000252
29    -5.0905940 -4.498779e 00     0.3184656    1.59565600  0.0009931505  0.0116114100 -0.0049441880  0.0077095150 -0.0056366920  1.981512e-02 -0.0163032500 -0.016945080 VA01.000252
30   -10.7903100 -8.233760e 00    -6.7355710   -1.88403700  0.0185493100  0.0146813200 -0.0025107030  0.0140376200  0.0120996500  1.894019e-02 -0.0016933080  0.074631690 VA01.000252
31   -10.7472500 -3.507028e 00    -0.1868369   -0.01676401  0.0169766300  0.0082867090  0.0059551180  0.0086740850  0.0118743400  1.064398e-02  0.0108309100  0.123264800 VA01.000252
32    -8.8624510 -4.327910e 00    -1.9420190    0.05665708  0.0087855510 -0.0141147600  0.0164769500  0.0007412076  0.0130740800 -1.723886e-04  0.0235768200  0.111186500 VA01.000252
33    -4.1893760 -4.628457e 00    -1.0422120    2.16047900  0.0096208300 -0.0303383700  0.0185003800  0.0002016187  0.0023077250  2.610683e-05  0.0196681900  0.031342030 VA01.000252
34    -2.5935570 -7.604697e 00    -6.2509840   -1.77888000  0.0159274900 -0.0354746000  0.0100154900  0.0027364130  0.0022544260  9.940148e-04  0.0233995400 -0.016331980 VA01.000252
35    -0.3843622 -8.656120e 00    -8.2879270   -4.46927800  0.0119029500 -0.0372953300 -0.0117585300 -0.0065452820 -0.0074253200 -2.392042e-03  0.0032024020 -0.044989680 VA01.000252
 [ reached 'max' / getOption("max.print") -- omitted 5732 rows ]

$VA01.000306
   VA01_F0finEnv VA01_F0final VA01_Jitter VA01_Shimmer VA01_MFCC.0.  VA01_MFCC.1.  VA01_MFCC.2.  VA01_MFCC.3.  VA01_MFCC.4.  VA01_MFCC.5.  VA01_MFCC.6.  VA01_MFCC.7.  VA01_MFCC.8.  VA01_MFCC.9. VA01_MFCC.10.
1        0.00000       0.0000  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
2        0.00000       0.0000  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
3        0.00000       0.0000  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
4       66.06307       0.0000  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
5      132.07510     197.8827  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
6      198.10720     198.0143  0.00000000   0.00000000   -132.83340  4.071416e-06 -2.168415e-06 -8.838955e-06 -1.102504e-05 -4.339662e-06 -4.926738e-06 -5.424289e-06  2.328874e-05 -3.056164e-06  3.144405e-06
7      198.26770     198.7493  0.00000000   0.00000000   -132.76600 -1.608481e-01  2.037154e-01 -1.779812e-01  9.700684e-02  1.798067e-03 -7.682262e-02  1.031989e-01 -8.462158e-02  4.960256e-02 -3.486202e-02
8      198.47930     199.3359  0.00000000   0.00000000   -121.87960 -3.967190e 00 -3.192784e 00 -5.713863e 00  1.134993e 00  1.154983e 00  9.564801e-01 -4.689783e 00 -7.461606e 00 -4.408395e 00 -2.726076e 00
9      198.67080       0.0000  0.00000000   0.00000000   -106.01020 -7.278543e 00 -3.143362e 00 -7.678925e 00  1.252466e 00  3.508399e 00  3.603816e 00 -6.568146e 00 -1.219917e 01 -8.938245e 00 -4.760966e 00
10     198.67080       0.0000  0.00000000   0.00000000    -88.07464 -1.064713e 01 -3.466723e 00 -8.576050e 00 -1.456704e-01  3.247663e 00  5.926846e 00 -5.519067e 00 -1.191534e 01 -1.394501e 01 -6.998346e 00
11     198.67080       0.0000  0.00000000   0.00000000    -80.93438 -9.849090e 00 -9.713004e-01 -8.205815e 00 -1.488182e 00  3.519478e 00  6.352642e 00 -6.546592e-01 -1.065193e 01 -1.600990e 01 -1.040968e 01
12     198.67080       0.0000  0.00000000   0.00000000    -79.00248 -9.464789e 00 -1.925519e 00 -1.044870e 01 -3.597581e 00  1.343774e 00  3.038982e 00 -1.895679e 00 -1.008268e 01 -1.576755e 01 -1.100388e 01
13     198.67080       0.0000  0.00000000   0.00000000    -78.68784 -8.090163e 00 -1.151505e 00 -1.209496e 01 -3.559671e 00  6.267379e 00  5.489735e 00 -4.759048e 00 -1.185489e 01 -1.706914e 01 -1.093319e 01
14     198.67080       0.0000  0.00000000   0.00000000    -78.79014 -8.380761e 00 -9.766474e-02 -1.078117e 01 -5.220814e 00  9.307704e 00  8.080084e 00 -4.081142e 00 -1.091573e 01 -1.736321e 01 -7.666967e 00
15     198.67080       0.0000  0.00000000   0.00000000    -79.22456 -9.115808e 00  1.081932e 00 -8.506924e 00 -2.938123e 00  1.174738e 01  1.082476e 01  3.139020e 00 -9.303253e 00 -2.145798e 01 -1.527955e 01
16     198.67080       0.0000  0.00000000   0.00000000    -80.14222 -1.213338e 01 -7.340708e-01 -8.718815e 00 -3.507613e 00  9.925209e 00  1.065111e 01  6.387280e 00 -1.099699e 01 -2.084829e 01 -1.644949e 01
17     195.89060       0.0000  0.00000000   0.00000000    -80.15101 -1.280754e 01 -1.856982e 00 -8.352854e 00 -3.509328e 00  9.267162e 00  1.285822e 01  5.557889e 00 -7.933638e 00 -2.049224e 01 -1.513887e 01
18     184.06050     123.5198  0.00000000   0.11428570    -79.48799 -1.235851e 01 -3.996706e 00 -1.122404e 01 -7.043495e 00  8.000949e 00  1.522155e 01  3.694560e 00 -9.202942e 00 -1.680342e 01 -7.392848e 00
19     172.23040     123.5198  0.00000000   0.11428570    -78.76895 -1.094779e 01 -2.618861e 00 -1.163724e 01 -6.205026e 00  6.073919e 00  1.088056e 01  1.764434e 00 -9.810312e 00 -1.693564e 01 -9.109813e 00
20     163.18040       0.0000  0.00000000   0.00000000    -78.83241 -1.082675e 01 -2.048099e 00 -1.260225e 01 -5.107279e 00  6.959501e 00  7.311881e 00  9.333791e-01 -1.523799e 01 -1.837118e 01 -1.260276e 01
21     163.18040       0.0000  0.00000000   0.00000000    -78.91582 -1.128211e 01 -1.939038e 00 -1.198381e 01 -2.955843e 00  8.080180e 00  5.157021e 00 -2.219907e 00 -1.709181e 01 -1.925593e 01 -1.429097e 01
22     163.18040       0.0000  0.00000000   0.00000000    -79.14918 -1.187961e 01 -4.606882e 00 -1.436339e 01 -5.666852e 00  7.484605e 00  7.751854e 00 -1.408785e 00 -1.877233e 01 -2.082530e 01 -1.180434e 01
23     162.92160       0.0000  0.00000000   0.00000000    -78.71255 -1.165900e 01 -5.774180e 00 -1.489697e 01 -6.975042e 00  7.643351e 00  1.062784e 01 -1.214756e 00 -1.600865e 01 -1.935155e 01 -1.167332e 01
24     162.38230     159.5562  0.00000000   0.34480520    -78.32827 -1.110361e 01 -4.696647e 00 -1.446761e 01 -9.409133e 00  8.060999e 00  1.240113e 01  1.600903e 00 -1.388438e 01 -1.901190e 01 -1.323320e 01
25     161.84300     159.5562  0.02605728   0.34480520    -78.05312 -1.014990e 01 -4.194228e 00 -1.446838e 01 -7.602672e 00  1.037379e 01  1.168037e 01  3.042128e 00 -1.116083e 01 -1.624155e 01 -1.445463e 01
26     161.56240       0.0000  0.00000000   0.00000000    -78.28783 -1.022662e 01 -4.232670e 00 -1.574872e 01 -1.037296e 01  5.956004e 00  8.997490e 00  5.673818e 00 -7.355112e 00 -1.510233e 01 -1.407658e 01
27     189.80080       0.0000  0.00000000   0.00000000    -78.24438 -1.039496e 01 -3.845754e 00 -1.545781e 01 -1.154140e 01  1.043898e 00  4.521493e 00  1.283444e 00 -5.130599e 00 -1.322520e 01 -1.050665e 01
28     215.07100     355.5413  0.17606220   0.17721520    -71.83294 -1.055411e 01 -9.035656e 00 -1.396300e 01 -2.243945e 01 -9.757606e-01 -5.280579e 00 -3.433941e 00  2.892552e 00 -8.381774e 00 -3.542657e 00
29     238.11510     307.2474  0.23347940   0.33169250    -59.79242 -1.171381e 01 -2.098286e 01 -1.385123e 01 -3.303093e 01 -5.412680e 00 -2.123938e 01 -1.005760e 01  3.904564e 00 -6.384818e 00 -1.586752e 00
30     230.96290     209.5061  0.29089660   0.48616990    -49.27115 -1.392087e 01 -3.236838e 01 -1.421863e 01 -3.724126e 01 -6.109905e 00 -2.639729e 01 -9.336800e 00  6.256122e 00 -4.542089e 00 -1.966711e 00
31     225.33530     208.4524  0.32635720   0.46714530    -45.53091 -1.749703e 01 -3.369137e 01 -1.479991e 01 -3.038074e 01 -8.142799e 00 -2.605631e 01 -1.447982e 01 -9.944237e-01 -2.663234e 00 -4.074055e 00
32     220.50210     206.0027  0.28348730   0.33599320    -46.05356 -1.819530e 01 -2.722596e 01 -1.566170e 01 -2.545187e 01 -9.136411e 00 -2.103490e 01 -1.660941e 01 -7.029628e 00 -3.040166e 00 -2.160725e 00
33     217.62700     205.4046  0.25107400   0.18366620    -45.55620 -1.684520e 01 -2.420651e 01 -1.970534e 01 -2.999458e 01 -1.458438e 01 -2.223171e 01 -2.637294e 01 -1.204367e 01 -8.770335e 00 -3.327812e 00
34     208.41580       0.0000  0.00000000   0.00000000    -46.67697 -1.377373e 01 -2.377385e 01 -2.049387e 01 -3.327609e 01 -1.877609e 01 -2.287036e 01 -2.651708e 01 -1.347084e 01 -1.668647e 01 -9.290524e 00
35     194.79400     122.7954  0.00000000   0.08908486    -49.53526 -1.144753e 01 -2.311539e 01 -1.823720e 01 -3.029245e 01 -1.655422e 01 -2.250204e 01 -2.738014e 01 -1.021846e 01 -1.846288e 01 -1.217965e 01
   VA01_MFCC.11. VA01_MFCC.12. VA01_MFCC.13. VA01_MFCC.14.  VA01_LPCC.0.  VA01_LPCC.1.  VA01_LPCC.2.  VA01_LPCC.3. VA01_LPCC.4. VA01_LPCC.5.  VA01_LPCC.6. VA01_LPCC.7.          ID
1     0.00000000 -2.515524e-05   0.000000000     0.0000000  0.0000000000  0.000000e 00  0.0000000000  0.000000e 00  0.000000000  0.000000000  0.0000000000  0.000000000 VA01.000306
2     0.00000000 -2.515524e-05   0.000000000     0.0000000  0.0000000000  0.000000e 00  0.0000000000  0.000000e 00  0.000000000  0.000000000  0.0000000000  0.000000000 VA01.000306
3     0.00000000 -2.515524e-05   0.000000000     0.0000000  0.0000000000  0.000000e 00  0.0000000000  0.000000e 00  0.000000000  0.000000000  0.0000000000  0.000000000 VA01.000306
4     0.00000000 -2.515524e-05   0.000000000     0.0000000  0.0000000000  0.000000e 00  0.0000000000  0.000000e 00  0.000000000  0.000000000  0.0000000000  0.000000000 VA01.000306
5     0.00000000 -2.515524e-05   0.000000000     0.0000000 -0.0184076200  9.056473e-03  0.0144565800  2.283082e-02  0.005367971 -0.016040800 -0.0146379500 -0.007172394 VA01.000306
6     0.00000000 -2.515524e-05   0.000000000     0.0000000 -0.0209243200  9.568262e-03  0.0113423000  2.198169e-02 -0.019443140 -0.050676060 -0.0677197900 -0.040398310 VA01.000306
7     0.06539222 -1.412173e-01   0.237491400    -0.3174207 -0.0229948600  8.532882e-04 -0.0115414000 -8.990550e-03 -0.058245430 -0.100676800 -0.1372327000 -0.122148300 VA01.000306
8    -4.37741500  1.803633e 00   3.425538000    -0.6892197 -0.0040151300 -2.266257e-02 -0.0533619000 -6.410563e-02 -0.101891100 -0.124211800 -0.1802628000 -0.162386500 VA01.000306
9    -9.89371100 -3.151391e 00  -2.073238000    -5.0481540  0.0135138500 -4.182792e-02 -0.0786013200 -9.732567e-02 -0.098515380 -0.102815900 -0.1375204000 -0.123732900 VA01.000306
10  -13.06223000 -8.547875e 00  -6.314475000    -8.2038350  0.0085990670 -3.566868e-02 -0.0608629200 -6.927581e-02 -0.057114730 -0.054313040 -0.0625234800 -0.036701250 VA01.000306
11  -13.68517000 -1.260925e 01 -10.912510000    -9.2799120  0.0089780060 -2.101706e-02 -0.0382256600 -3.866750e-02 -0.019559390 -0.005071664 -0.0063958290  0.043028330 VA01.000306
12  -11.78058000 -1.188147e 01  -9.992681000    -9.3035850 -0.0005370945 -1.425588e-03 -0.0207772500 -1.034291e-02  0.006887400  0.014138790  0.0064576860  0.041679860 VA01.000306
13  -12.39182000 -1.063661e 01  -8.604159000    -8.2113140  0.0018913630 -3.343820e-06 -0.0224462900 -6.278396e-03 -0.002774501  0.019274760 -0.0087256430  0.011642150 VA01.000306
14   -9.03315700 -1.035321e 01  -9.103490000    -9.5553970  0.0116867900 -8.631110e-04 -0.0158921400  4.952478e-03 -0.001150823  0.010702200 -0.0016864060 -0.020302080 VA01.000306
15  -10.35934000 -8.725303e 00  -9.200974000    -9.0803590  0.0161392800 -4.324913e-04 -0.0043746830  1.749072e-02 -0.013208830  0.003553331 -0.0101731100 -0.042878200 VA01.000306
16   -5.89269100 -5.816070e 00  -8.720405000   -10.0847800  0.0261641400  6.739259e-04 -0.0016429900  1.372378e-02 -0.009260702 -0.007415831 -0.0176958300 -0.015496280 VA01.000306
17   -3.77296500 -6.431228e 00  -9.740609000    -8.0220400  0.0200454400  1.815557e-03  0.0020712850  6.656432e-03  0.004487693 -0.008758676 -0.0161009700  0.034472470 VA01.000306
18    3.79097700 -3.031355e 00  -6.206137000    -6.6857320  0.0037428680 -9.724915e-04 -0.0011125740 -4.260778e-03  0.010261450 -0.008401990 -0.0090872890  0.045690630 VA01.000306
19    0.67445280 -4.334564e 00  -6.363834000    -6.2280070 -0.0051062170  1.509130e-04  0.0046405910 -7.197058e-03  0.007973838 -0.002276134  0.0074429750  0.007382536 VA01.000306
20   -0.10288890 -3.435024e 00  -8.231669000    -5.1356100 -0.0062805060  1.151091e-03  0.0048226540 -5.702293e-03 -0.009571719  0.003418457  0.0073548080 -0.050245380 VA01.000306
21   -5.45035000 -6.662785e 00  -9.573838000    -4.3247210  0.0114863900  2.182883e-03  0.0006759643 -1.997161e-03 -0.009586597  0.002171934  0.0002043843 -0.051995450 VA01.000306
22   -4.59960700 -5.267791e 00  -7.929319000    -2.9512640  0.0216825100 -2.752215e-03  0.0017896890  5.552781e-03  0.008655417  0.002773154  0.0037880060  0.020975780 VA01.000306
23   -3.81252200 -3.772803e 00  -0.007905643    -7.6452020  0.0215653800 -8.009851e-03 -0.0062661940 -4.932248e-03  0.012868800 -0.012286290 -0.0085459470  0.017369340 VA01.000306
24   -6.09944400 -8.275232e-01   5.833414000    -5.3595730  0.0090239590 -1.090450e-02 -0.0049693350 -1.628364e-02  0.003197253 -0.024063070 -0.0179085400 -0.027566050 VA01.000306
25   -5.00031700  1.417589e 00   9.046644000    -5.6115060 -0.0059578300 -1.054165e-02 -0.0013398230 -2.034221e-02 -0.014098660 -0.028090860 -0.0261412000 -0.088006120 VA01.000306
26   -4.32760900  1.193695e-01   4.182911000    -2.3224180 -0.0106227500 -5.331552e-03  0.0093770030 -1.228528e-02 -0.008016026 -0.007219779 -0.0058196070 -0.061706090 VA01.000306
27   -2.02719300 -2.232354e 00  -1.922027000    -5.8191990 -0.0115118000 -4.980325e-04  0.0278375900  3.455162e-03  0.004852235  0.020685300  0.0224943800  0.013529660 VA01.000306
28    0.33683010 -7.554343e 00  -7.841676000    -3.7929660  0.0005819201  1.188021e-02  0.0411942200  6.827247e-03  0.005246246  0.037717160  0.0344581000  0.053223440 VA01.000306
29   -0.07882365 -7.312241e 00 -11.804320000    -4.6076220  0.0090806190  2.742716e-02  0.0420391900  4.901671e-03 -0.011491610  0.024458040  0.0099282020  0.033220890 VA01.000306
30    3.10978900 -7.719881e 00 -11.903180000    -2.8615630  0.0094116540  3.456013e-02  0.0272117000  5.191803e-04 -0.019723570  0.003737843 -0.0213120100 -0.009961438 VA01.000306
31    4.06748200 -5.840994e 00  -7.382002000    -3.2604420  0.0006239027  2.369088e-02 -0.0049061780 -6.793499e-04 -0.008937096 -0.006194902 -0.0266406300 -0.017134380 VA01.000306
32    4.61851500 -3.815072e 00  -1.306985000    -3.0752270 -0.0160616500 -5.648232e-03 -0.0284065600  9.139776e-05 -0.006431472 -0.002867937 -0.0156098000 -0.031704280 VA01.000306
33    5.76366100  9.971380e-02  -0.880500300     2.5799500 -0.0193500600 -2.538468e-02 -0.0310111100 -1.618230e-03 -0.008179879  0.003644753  0.0053020590 -0.015477420 VA01.000306
34    4.89582800  3.213499e 00  -5.585051000     6.9467100 -0.0172611500 -1.858063e-02 -0.0166882200 -1.277434e-02 -0.012023590 -0.005265963  0.0038234830  0.004599357 VA01.000306
35   -0.52219870 -2.609112e 00  -5.826841000     9.4508730 -0.0057473420  2.861196e-03  0.0008089423 -1.566776e-02  0.002669394 -0.018476300  0.0140653400  0.070357040 VA01.000306
 [ reached 'max' / getOption("max.print") -- omitted 6444 rows ]

This is my approach:

for (i in 1:length(F_10)){
  for (j in 1:4){                           
    for (k in 1:length(F_10[[i]][[j]])){
      if ( F_10[[i]][[j]][k] == 0 ){
        F_10[[i]][[j]][k] <-  NA
      }
    }
  }
}

CodePudding user response:

If I understand it correctly and your inner lists are data frames, you only need one loop:

F_10 <- data.frame(a=0:2, b=c(1, 0, 0), c=0:2, d=0:2, e=0:2)
F_10 <- list(F_10, F_10)
# [[1]]
#   a b c d e
# 1 0 1 0 0 0
# 2 1 0 1 1 1
# 3 2 0 2 2 2
# 
# [[2]]
#   a b c d e
# 1 0 1 0 0 0
# 2 1 0 1 1 1
# 3 2 0 2 2 2

col.i <- 1:4
for (i in seq_along(F_10)) {
  F_10[[i]][, col.i][F_10[[i]][, col.i]==0] <- NA
}
# [[1]]
#    a  b  c  d e
# 1 NA  1 NA NA 0
# 2  1 NA  1  1 1
# 3  2 NA  2  2 2
# 
# [[2]]
#    a  b  c  d e
# 1 NA  1 NA NA 0
# 2  1 NA  1  1 1
# 3  2 NA  2  2 2
  • Related