[R] split data frame and manipulate

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu May 26 12:58:34 CEST 2011



On 26.05.2011 12:01, Mathew Brown wrote:
> Hello,
>
> I would like to split the attached data frame based on the DATE
> variable. I'm having a real problem doing this. I am able to split
>
> iso<-read.table(datuh.dat, header=TRUE, sep="", dec=".") #load
> mylist=split(iso,iso$DATE) #split
> str(mylist) #result seems a bit odd
>
>
> However, after splitting I'm not able to call up certain variables of
> the two lists. For instance, this does not work
> mylist$2011-05-25

"2011-05-25" is not a regular name, hence quote it or use the safe

mylist[["2011-05-25"]]

approach right away.

Uwe Ligges


> Could anyone point suggest a way to do this. I want to be able to fully
> manipulate and plot variables from each of the resulting data frames.
>
> Thanks,
>
>
>
> datuh.dat
>
>
> DATE                      TIME                      FRAC_DAYS_SINCE_JAN1      FRAC_HRS_SINCE_JAN1       EPOCH_TIME                ALARM_STATUS              CavityPressure            CavityTemp                WarmBoxTemp               DasTemp                   EtalonTemp                MPVPosition               OutletValve               ValveMask                 h2o_ppmv                  delta_18_16               delta_18_16_30s           delta_18_16_2min          delta_18_16_5min          delta_D_H                 delta_D_H_30sec           delta_D_H_2min            delta_D_H_5min            organic_82                organic_MeOHampl          organic_base              organic_c2h6conc          organic_ch4conc           organic_res               organic_shift             organic_slope             organic_splinemax         organic_squish            organic_y                 standard_base             standard_residuals        n2_flag
> 2011-05-17                04:34:38.478              136.19072313              3268.577355               1305578078.479            0                         3.4988197140E+001         7.9992855518E+001         4.5000930239E+001         4.2875000000E+001         4.4899361751E+001         0.0000000000E+000         3.4622264077E+004         0.0000000000E+000         2.8088560421E+004         -1.9467533827E+001        -2.7893076931E+001        -2.7743936767E+001        -2.7753529823E+001        -1.2377256723E+002        0.0000000000E+000         -9.5744106980E+001        -9.5568392994E+001        -4.4796408335E+001        6.3655609575E-003         1.1421008841E+003         0.0000000000E+000         6.4427827420E-003         1.4967341225E+001         -5.4285889258E-005        1.2185491102E+002         3.7705963994E+003         1.9097284875E-002         1.0909446897E+000         1.1583693575E+003         5.1403883393E+000         1.0000000000E+000
> 2011-05-17                04:34:40.656              136.19074834              3268.577960               1305578080.657            0                         3.5005070265E+001         7.9991783142E+001         4.5000907898E+001         4.2875000000E+001         4.4899406433E+001         0.0000000000E+000         3.4629223659E+004         0.0000000000E+000         2.8092153488E+004         -1.9244932987E+001        -2.7902076424E+001        -2.7748467245E+001        -2.7753748377E+001        -1.2377134463E+002        0.0000000000E+000         -9.5733066602E+001        -9.5597052107E+001        -4.6333695381E+001        6.0838715982E-003         1.1444241331E+003         0.0000000000E+000         6.9345887992E-003         1.4506769500E+001         -6.6888225576E-005        1.2425494753E+002         3.7718270556E+003         1.7754238929E-002         1.0909413434E+000         1.1590081910E+003         5.2925204692E+000         1.0000000000E+000
> 2011-05-17                04:34:42.789              136.19077303              3268.578553               1305578082.790            0                         3.5011287214E+001         7.9991783142E+001         4.5000907898E+001         4.2875000000E+001         4.4899406433E+001         0.0000000000E+000         3.4639727167E+004         0.0000000000E+000         2.8092141828E+004         -1.9135178021E+001        -2.7910810452E+001        -2.7754150771E+001        -2.7753942994E+001        -1.2460876390E+002        0.0000000000E+000         -9.5756653790E+001        -9.5589107952E+001        -4.5145515060E+001        5.7674651737E-003         1.1440425640E+003         0.0000000000E+000         6.8179220240E-003         1.6203128394E+001         -6.6248484141E-005        1.2677702864E+002         3.7737261955E+003         1.4980330424E-002         1.0906977446E+000         1.1586517066E+003         5.1631797704E+000         1.0000000000E+000
> 2011-05-17                04:34:44.856              136.19079695              3268.579127               1305578084.857            0                         3.4991743440E+001         7.9992732066E+001         4.5000789282E+001         4.2875000000E+001         4.4899453879E+001         0.0000000000E+000         3.4631112205E+004         0.0000000000E+000         2.8078270782E+004         -1.9441261828E+001        -2.7912261440E+001        -2.7768060260E+001        -2.7754924380E+001        -1.2207858039E+002        0.0000000000E+000         -9.5718277539E+001        -9.5589524089E+001        -4.3215852278E+001        7.0021250365E-003         1.1388662396E+003         0.0000000000E+000         6.5306517966E-003         1.5614854104E+001         -5.7535929126E-005        1.2217591813E+002         3.7688512106E+003         1.0665374520E-002         1.0907567377E+000         1.1585466627E+003         5.0230177167E+000         1.0000000000E+000
> 2011-05-17                04:34:46.947              136.19082115              3268.579708               1305578086.948            0                         3.4984864418E+001         7.9993003845E+001         4.5000755310E+001         4.2875000000E+001         4.4899467468E+001         0.0000000000E+000         3.4619560363E+004         0.0000000000E+000         2.8083261462E+004         -1.9382042613E+001        -2.7921823693E+001        -2.7773438733E+001        -2.7757645655E+001        -1.2422150608E+002        0.0000000000E+000         -9.5713134878E+001        -9.5587200379E+001        -4.7218925145E+001        4.9768729013E-003         1.1490330493E+003         0.0000000000E+000         6.1104491472E-003         1.5372943363E+001         -5.6778264657E-005        1.2113422015E+002         3.7706396932E+003         7.9605843519E-003         1.0907998955E+000         1.1586357653E+003         5.3871698531E+000         1.0000000000E+000
> 2011-05-17                04:34:49.029              136.19084525              3268.580286               1305578089.030            0                         3.4999587754E+001         7.9992763159E+001         4.5000653969E+001         4.2875000000E+001         4.4899404130E+001         0.0000000000E+000         3.4625309876E+004         0.0000000000E+000         2.8094292439E+004         -1.8885233876E+001        -2.7907491123E+001        -2.7771015336E+001        -2.7755778910E+001        -1.2614001905E+002        0.0000000000E+000         -9.5738865535E+001        -9.5611556742E+001        -4.5402788279E+001        6.3337561060E-003         1.1430250675E+003         0.0000000000E+000         6.1912065016E-003         1.6242739910E+001         -4.3442404332E-005        1.1775047149E+002         3.7707076441E+003         1.6253442729E-002         1.0907494093E+000         1.1593930583E+003         4.9062838448E+000         1.0000000000E+000
> 2011-05-17                04:34:51.127              136.19086953              3268.580869               1305578091.127            0                         3.4998030378E+001         7.9992424011E+001         4.5000511169E+001         4.2875000000E+001         4.4899314880E+001         0.0000000000E+000         3.4625663723E+004         0.0000000000E+000         2.8099153347E+004         -1.9052396778E+001        -2.7909267713E+001        -2.7768635323E+001        -2.7756108005E+001        -1.2476622761E+002        0.0000000000E+000         -9.5728295875E+001        -9.5618387810E+001        -4.6131861478E+001        5.3882778941E-003         1.1464559957E+003         0.0000000000E+000         6.6151466275E-003         1.5410802286E+001         -3.4697307946E-005        1.2575260884E+002         3.7742850451E+003         1.5606652682E-002         1.0908251986E+000         1.1588033922E+003         5.2436024752E+000         1.0000000000E+000
> 2011-05-17                04:34:53.229              136.19089386              3268.581453               1305578093.230            0                         3.5002183590E+001         7.9992424011E+001         4.5000511169E+001         4.2875000000E+001         4.4899314880E+001         0.0000000000E+000         3.4622515021E+004         0.0000000000E+000         2.8117887378E+004         -1.9189874852E+001        -2.7890176912E+001        -2.7778177250E+001        -2.7754786413E+001        -1.2456804576E+002        0.0000000000E+000         -9.5744288911E+001        -9.5636909677E+001        -4.4664006304E+001        6.7036644537E-003         1.1408304482E+003         0.0000000000E+000         7.1441849170E-003         1.5687378148E+001         -3.8643451738E-005        1.1872381056E+002         3.7733764669E+003         1.5736028592E-002         1.0908486392E+000         1.1591937597E+003         5.1022469256E+000         1.0000000000E+000
> 2011-05-17                04:34:55.368              136.19091861              3268.582047               1305578095.368            0                         3.5014122859E+001         7.9992858628E+001         4.5000690129E+001         4.2875000000E+001         4.4899442709E+001         0.0000000000E+000         3.4638578685E+004         0.0000000000E+000         2.8124182638E+004         -1.9205844250E+001        -2.7876406465E+001        -2.7782151201E+001        -2.7754400634E+001        -1.2219631326E+002        0.0000000000E+000         -9.5686170039E+001        -9.5638962264E+001        -4.7269475299E+001        4.6245760673E-003         1.1497314131E+003         0.0000000000E+000         6.5943531131E-003         1.4517439913E+001         -5.3607696174E-005        1.2876988268E+002         3.7792985058E+003         1.6320030425E-002         1.0909808161E+000         1.1581980653E+003         5.2885226217E+000         1.0000000000E+000
> 2011-05-17                04:34:57.458              136.19094280              3268.582627               1305578097.458            0                         3.4988202135E+001         7.9992942810E+001         4.5000724792E+001         4.2875000000E+001         4.4899467468E+001         0.0000000000E+000         3.4626708491E+004         0.0000000000E+000         2.8105131331E+004         -1.9293745707E+001        -2.7863594960E+001        -2.7790053082E+001        -2.7755710571E+001        -1.2532250364E+002        0.0000000000E+000         -9.5668035702E+001        -9.5644693115E+001        -4.3948056641E+001        6.6284057579E-003         1.1403376041E+003         0.0000000000E+000         6.6706399122E-003         1.5533423112E+001         -6.9902518208E-005        1.1942027419E+002         3.7726523906E+003         1.2862116133E-002         1.0908156074E+000         1.1589230297E+003         5.0350585348E+000         1.0000000000E+000
> 2011-05-17                04:34:59.472              136.19096612              3268.583187               1305578099.473            0                         3.5006331188E+001         7.9993062577E+001         4.5000617002E+001         4.2875000000E+001         4.4899467468E+001         0.0000000000E+000         3.4625722361E+004         0.0000000000E+000         2.8111163458E+004         -1.8894235459E+001        -2.7851898201E+001        -2.7789554904E+001        -2.7755471699E+001        -1.2294079969E+002        0.0000000000E+000         -9.5675362352E+001        -9.5635758146E+001        -4.5946993758E+001        5.7493781440E-003         1.1453574403E+003         0.0000000000E+000         6.3509490062E-003         1.6121943858E+001         -9.6979306319E-005        1.1719224835E+002         3.7733981596E+003         2.0113196491E-002         1.0908132454E+000         1.1588842353E+003         5.2708894114E+000         1.0000000000E+000
> 2011-05-16                04:35:01.555              137.19099023              3268.583765               1305578101.556            0                         3.5014545225E+001         7.9993247986E+001         4.5000450134E+001         4.2875000000E+001         4.4899467468E+001         0.0000000000E+000         3.4638007680E+004         0.0000000000E+000         2.8121464020E+004         -1.9008137335E+001        -2.7840666789E+001        -2.7790340299E+001        -2.7755846729E+001        -1.2688503377E+002        0.0000000000E+000         -9.5693409593E+001        -9.5657465192E+001        -4.5108768708E+001        6.5677126649E-003         1.1420599552E+003         0.0000000000E+000         6.5363180871E-003         1.6244505581E+001         -1.6346041349E-005        1.2175671439E+002         3.7742366986E+003         1.5272728374E-002         1.0907789978E+000         1.1593404540E+003         5.2443592547E+000         1.0000000000E+000
> 2011-05-16                04:35:03.712              137.19101519              3268.584365               1305578103.713            0                         3.4977787766E+001         7.9993247986E+001         4.5000425144E+001         4.2875000000E+001         4.4899449618E+001         0.0000000000E+000         3.4621506235E+004         0.0000000000E+000         2.8121620732E+004         -1.9077602601E+001        -2.7828640224E+001        -2.7798056724E+001        -2.7757437911E+001        -1.2346433520E+002        0.0000000000E+000         -9.5664367007E+001        -9.5651969260E+001        -4.5858323646E+001        6.2652685752E-003         1.1435646758E+003         0.0000000000E+000         6.4875878790E-003         1.5751203783E+001         -1.6097972070E-005        1.1869665310E+002         3.7728900981E+003         1.4970836561E-002         1.0908529867E+000         1.1582634416E+003         5.0060012045E+000         1.0000000000E+000
> 2011-05-16                04:35:05.832              137.19103973              3268.584954               1305578105.833            0                         3.4993729645E+001         7.9993247986E+001         4.5000236511E+001         4.2875000000E+001         4.4899314880E+001         0.0000000000E+000         3.4621927624E+004         0.0000000000E+000         2.8128479932E+004         -1.9349011232E+001        -2.7840159794E+001        -2.7803879104E+001        -2.7760431507E+001        -1.2501437129E+002        0.0000000000E+000         -9.5710112755E+001        -9.5658412386E+001        -4.7729459635E+001        4.6239646546E-003         1.1503008951E+003         0.0000000000E+000         6.2380097003E-003         1.4610542605E+001         -5.6065484565E-005        1.2599522333E+002         3.7787486192E+003         1.6223791643E-002         1.0910338585E+000         1.1585456968E+003         5.2480266971E+000         1.0000000000E+000
> 2011-05-16                04:35:07.894              137.19106359              3268.585526               1305578107.895            0                         3.4993845094E+001         7.9993247986E+001         4.5000236511E+001         4.2875000000E+001         4.4899314880E+001         0.0000000000E+000         3.4609889195E+004         0.0000000000E+000         2.8141683402E+004         -1.9184147966E+001        -2.7842372511E+001        -2.7805834985E+001        -2.7762833361E+001        -1.2431439085E+002        0.0000000000E+000         -9.5721536917E+001        -9.5655424710E+001        -4.3204799486E+001        6.9931683360E-003         1.1383302408E+003         0.0000000000E+000         7.3559259543E-003         1.4972623017E+001         -6.8481687086E-005        1.1373435719E+002         3.7760080331E+003         2.0986992732E-002         1.0910397027E+000         1.1592777856E+003         5.0675304002E+000         1.0000000000E+000
> 2011-05-16                04:35:11.300              137.19110301              3268.586472               1305578111.300            0                         3.5005244446E+001         7.9992759705E+001         4.5000236511E+001         4.2875000000E+001         4.4899101257E+001         0.0000000000E+000         3.4622065772E+004         0.0000000000E+000         2.8177726347E+004         -1.9224405453E+001        -2.7823332741E+001        -2.7812119320E+001        -2.7764505429E+001        -1.2365860212E+002        0.0000000000E+000         -9.5685334502E+001        -9.5653296878E+001        -4.5435246287E+001        5.8041527643E-003         1.1447150955E+003         0.0000000000E+000         6.1759018545E-003         1.6185450517E+001         7.1933733128E-006         1.1592685407E+002         3.7822433383E+003         2.2082050519E-002         1.0909831007E+000         1.1591997885E+003         5.0366022514E+000         1.0000000000E+000
> 2011-05-16                04:35:13.328              137.19112648              3268.587036               1305578113.328            0                         3.5013070607E+001         7.9992759705E+001         4.5000236511E+001         4.2875000000E+001         4.4899101257E+001         0.0000000000E+000         3.4634739166E+004         0.0000000000E+000         2.8176664775E+004         -1.8703483906E+001        -2.7795994063E+001        -2.7804997908E+001        -2.7762839324E+001        -1.2399216409E+002        0.0000000000E+000         -9.5679714903E+001        -9.5656673994E+001        -4.5153473257E+001        6.3027536252E-003         1.1429986914E+003         0.0000000000E+000         6.0633203776E-003         1.6892640332E+001         -9.8570200543E-005        1.1545230488E+002         3.7805922989E+003         1.4410433395E-002         1.0909169736E+000         1.1589221387E+003         5.1191869734E+000         1.0000000000E+000
> 2011-05-16                04:35:15.408              137.19115056              3268.587613               1305578115.409            0                         3.4991656825E+001         7.9992542281E+001         4.5000019088E+001         4.2875000000E+001         4.4899101257E+001         0.0000000000E+000         3.4620768779E+004         0.0000000000E+000         2.8197019495E+004         -1.9244935549E+001        -2.7783560953E+001        -2.7806609867E+001        -2.7763815877E+001        -1.2406519267E+002        0.0000000000E+000         -9.5670584729E+001        -9.5665926388E+001        -4.5769871950E+001        5.6210475754E-003         1.1447156958E+003         0.0000000000E+000         7.0469068074E-003         1.6117830136E+001         -8.1776923786E-005        1.1785796183E+002         3.7851211083E+003         1.1777629158E-002         1.0910556127E+000         1.1583953939E+003         5.3299090191E+000         1.0000000000E+000
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list