如何将列表的某些部分保存为 R 中的 csv 文件?

How to save certain parts of list as csv file in R?

很抱歉我不得不问这个问题,但我不是 R 用户。我想提取列表的某些部分('alltracks';请参阅列表的前 2 个示例数据框,还有更多)。我只想提取 2015 年之后的那些(da 显示日期)并将它们保存到 csvs(我了解到我不能将整个列表保存到 csv,因为它是一个列表。我可以保存列表的单个部分

christian=alltracks$`201300262`
write.csv(christian,'christiantrack.csv')

但是,我不想遍历整个列表并手动为每个步骤执行此操作。有人能帮我一下吗?非常感谢

$`197900552`
    da  INDEX   SIZE    AREA    x   y   RADIUS  MEANV   STDV    MINV    MAXV    LONMAX  LATMAX  SSIn    SSIs    SSIu    SSIan
    1979112518  552     281     15.624  6.34    55.50   385.39  16.54   1.60    9.14    19.32   6.75    55.78   0.10833     34.35   58714.7     0.00856
    1979112600  552     278     15.151  12.86   56.73   559.89  11.90   3.03    6.99    16.56   11.81   56.63   0.06744     7.42    24727.2     0.00533
    1979112606  552     466     24.697  20.44   57.64   532.80  14.02   3.31    7.47    19.04   21.38   58.03   0.61935     131.99  63774.7     0.04896
    1979112612  552     1425    77.713  14.96   56.00   1212.80     12.54   3.62    6.34    18.78   6.19    55.50   1.41075     191.44  155061.6    0.11151
    1979112618  552     2177    116.476     16.27   56.46   1326.51     11.92   4.23    4.79    20.28   3.09    59.44   3.08396     362.51  223131.4    0.24377
    1979112700  552     2120    113.008     20.43   56.77   1265.43     11.48   3.94    4.60    20.66   18.56   58.59   6.18199     611.18  190836.4    0.48865
    1979112706  552     2085    110.357     22.01   58.02   1405.91     10.70   3.80    6.06    21.21   20.81   58.31   6.78306     937.33  155298.2    0.53616
    1979112712  552     1388    75.601  20.64   56.96   733.87  10.95   3.64    6.44    20.86   20.53   57.47   3.93638     544.97  109821.5    0.31115
    1979112718  552     551     29.797  22.26   57.34   704.24  11.12   3.52    7.22    19.03   20.53   56.91   0.43983     66.69   43677.6     0.03477
$`197900676`
    da  INDEX   SIZE    AREA    x   y   RADIUS  MEANV   STDV    MINV    MAXV    LONMAX  LATMAX  SSIn    SSIs    SSIu    SSIan
    1979120400  676     403     24.572  -22.31  52.16   841.18  19.48   0.81    17.79   21.26   -21.66  52.69   0.08568     43.98   147660.2    0.00677
    1979120406  676     618     34.581  -13.74  56.43   1014.93     19.37   1.01    11.97   22.22   -15.47  58.03   0.13904     68.46   204977.1    0.01099
    1979120412  676     1185    65.675  -8.16   54.72   954.63  16.89   3.78    7.79    22.18   -11.81  55.22   1.99375     378.46  291927.7    0.15759
    1979120418  676     1673    85.419  -3.50   57.59   926.42  17.29   3.85    3.04    25.11   -9.56   61.97   5.84061     1312.08     406945.6    0.46166
    1979120500  676     1774    84.716  4.71    61.22   791.20  15.25   6.23    3.21    28.63   -0.56   61.69   18.58224    4315.25     364391.8    1.46881
    1979120506  676     2261    104.739     10.14   62.69   1034.28     12.73   5.61    2.70    28.72   5.62    64.22   25.85656    3178.16     286410.5    2.04379
    1979120512  676     2598    119.657     13.57   64.40   1398.30     11.01   5.14    3.77    27.06   10.12   65.90   20.69610    2377.04     230466.7    1.63589
    1979120518  676     1165    49.241  14.87   65.16   699.40  11.85   5.55    3.90    23.39   6.75    66.46   6.24648     773.22  114765.8    0.49374
    1979120600  676     1240    53.699  13.33   64.19   961.31  10.43   5.05    2.88    22.67   8.72    65.62   4.60729     356.15  89704.6     0.36418
    1979120606  676     786     36.521  11.49   63.35   813.28  9.16    3.90    2.67    19.89   9.28    64.22   3.49895     113.00  37390.4     0.27657 

尝试遍历列表元素的名称。

lapply(names(alltracks), \(x) 
       write.csv(alltracks[[x]], sprintf('christian_track_%s.csv', x)))

注: "R version 4.1.2 (2021-11-01)"