计算R中的均值

时间:2019-03-29 16:53:12

标签: r mean

我正在学习R,并且正在努力进行以下数据转换。我有一个像这样的数据集:

> dput(act.byHour_corr)
structure(list(hour = c(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 
23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 
17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 
21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L), 
    data_hour = structure(c(1529452800, 1529456400, 1529460000, 
    1529463600, 1529467200, 1529470800, 1529474400, 1529478000, 
    1529481600, 1529485200, 1529488800, 1529492400, 1529496000, 
    1529499600, 1529503200, 1529506800, 1529510400, 1529514000, 
    1529517600, 1529521200, 1529524800, 1529528400, 1529532000, 
    1529535600, 1529539200, 1529542800, 1529546400, 1529550000, 
    1529553600, 1529557200, 1529560800, 1529564400, 1529568000, 
    1529571600, 1529575200, 1529578800, 1529582400, 1529586000, 
    1529589600, 1529593200, 1529596800, 1529600400, 1529604000, 
    1529607600, 1529611200, 1529614800, 1529618400, 1529622000, 
    1529625600, 1529629200, 1529632800, 1529636400, 1529640000, 
    1529643600, 1529647200, 1529650800, 1529654400, 1529658000, 
    1529661600, 1529665200, 1529668800, 1529672400, 1529676000, 
    1529679600, 1529683200, 1529686800, 1529690400, 1529694000, 
    1529697600, 1529701200, 1529704800, 1529708400, 1529712000, 
    1529715600, 1529719200, 1529722800, 1529726400, 1529730000, 
    1529733600, 1529737200, 1529740800, 1529744400, 1529748000, 
    1529751600, 1529755200, 1529758800, 1529762400, 1529766000, 
    1529769600, 1529773200, 1529776800, 1529780400, 1529784000, 
    1529787600, 1529791200, 1529794800, 1529798400, 1529802000, 
    1529805600, 1529809200, 1529812800, 1529816400, 1529820000, 
    1529823600, 1529827200, 1529830800, 1529834400, 1529838000, 
    1529841600, 1529845200, 1529848800, 1529852400, 1529856000, 
    1529859600, 1529863200, 1529866800, 1529870400, 1529874000, 
    1529877600, 1529881200, 1529884800, 1529888400, 1529892000, 
    1529895600, 1529899200, 1529902800, 1529906400, 1529910000, 
    1529913600, 1529917200, 1529920800, 1529924400, 1529928000, 
    1529931600, 1529935200, 1529938800, 1529942400, 1529946000, 
    1529949600, 1529953200, 1529956800, 1529960400, 1529964000, 
    1529967600, 1529971200, 1529974800, 1529978400, 1529982000, 
    1529985600, 1529989200, 1529992800, 1529996400, 1.53e+09, 
    1530003600, 1530007200, 1530010800, 1530014400, 1530018000, 
    1530021600, 1530025200, 1530028800, 1530032400, 1530036000, 
    1530039600, 1530043200, 1530046800, 1530050400, 1530054000, 
    1530057600, 1530061200, 1530064800, 1530068400, 1530072000, 
    1530075600, 1530079200, 1530082800, 1530086400, 1530090000, 
    1530093600, 1530097200, 1530100800, 1530104400, 1530108000, 
    1530111600, 1530115200, 1530118800, 1530122400, 1530126000, 
    1530129600, 1530133200, 1530136800, 1530140400, 1530144000, 
    1530147600, 1530151200, 1530154800, 1530158400, 1530162000, 
    1530165600, 1530169200, 1530172800, 1530176400, 1530180000, 
    1530183600, 1530187200, 1530190800, 1530194400, 1530198000, 
    1530201600, 1530205200, 1530208800, 1530212400, 1530216000, 
    1530219600, 1530223200, 1530226800, 1530230400, 1530234000, 
    1530237600, 1530241200, 1530244800, 1530248400, 1530252000, 
    1530255600, 1530259200, 1530262800, 1530266400, 1530270000, 
    1530273600, 1530277200, 1530280800, 1530284400, 1530288000, 
    1530291600, 1530295200, 1530298800, 1530302400, 1530306000, 
    1530309600, 1530313200, 1530316800, 1530320400, 1530324000, 
    1530327600, 1530331200, 1530334800, 1530338400, 1530342000, 
    1530345600, 1530349200, 1530352800, 1530356400, 1530360000, 
    1530363600, 1530367200, 1530370800, 1530374400, 1530378000, 
    1530381600, 1530385200, 1530388800, 1530392400, 1530396000, 
    1530399600, 1530403200, 1530406800, 1530410400, 1530414000, 
    1530417600, 1530421200, 1530424800, 1530428400, 1530432000, 
    1530435600, 1530439200, 1530442800, 1530446400, 1530450000, 
    1530453600, 1530457200, 1530460800, 1530464400, 1530468000, 
    1530471600, 1530475200, 1530478800, 1530482400, 1530486000, 
    1530489600, 1530493200, 1530496800, 1530500400, 1530504000, 
    1530507600, 1530511200, 1530514800, 1530518400, 1530522000, 
    1530525600, 1530529200, 1530532800, 1530536400, 1530540000, 
    1530543600, 1530547200, 1530550800, 1530554400, 1530558000, 
    1530561600, 1530565200, 1530568800, 1530572400, 1530576000, 
    1530579600, 1530583200, 1530586800, 1530590400, 1530594000, 
    1530597600, 1530601200, 1530604800, 1530608400, 1530612000, 
    1530615600, 1530619200, 1530622800, 1530626400, 1530630000, 
    1530633600, 1530637200, 1530640800, 1530644400, 1530648000, 
    1530651600, 1530655200, 1530658800, 1530662400, 1530666000, 
    1530669600, 1530673200, 1530676800, 1530680400, 1530684000, 
    1530687600, 1530691200, 1530694800, 1530698400, 1530702000, 
    1530705600, 1530709200, 1530712800, 1530716400, 1530720000, 
    1530723600, 1530727200, 1530730800, 1530734400, 1530738000, 
    1530741600, 1530745200, 1530748800, 1530752400, 1530756000, 
    1530759600, 1530763200, 1530766800, 1530770400, 1530774000, 
    1530777600, 1530781200, 1530784800, 1530788400, 1530792000, 
    1530795600, 1530799200, 1530802800, 1530806400, 1530810000, 
    1530813600, 1530817200, 1530820800, 1530824400, 1530828000, 
    1530831600, 1530835200, 1530838800, 1530842400, 1530846000, 
    1530849600, 1530853200, 1530856800, 1530860400, 1530864000, 
    1530867600, 1530871200, 1530874800, 1530878400, 1530882000, 
    1530885600, 1530889200, 1530892800, 1530896400, 1530900000, 
    1530903600, 1530907200, 1530910800, 1530914400, 1530918000, 
    1530921600, 1530925200, 1530928800, 1530932400, 1530936000, 
    1530939600, 1530943200, 1530946800, 1530950400, 1530954000, 
    1530957600, 1530961200, 1530964800, 1530968400, 1530972000, 
    1530975600, 1530979200, 1530982800, 1530986400, 1530990000, 
    1530993600, 1530997200, 1531000800, 1531004400, 1531008000, 
    1531011600, 1531015200, 1531018800, 1531022400, 1531026000, 
    1531029600, 1531033200, 1531036800, 1531040400, 1531044000, 
    1531047600, 1531051200, 1531054800, 1531058400, 1531062000, 
    1531065600, 1531069200, 1531072800, 1531076400, 1531080000, 
    1531083600, 1531087200, 1531090800, 1531094400, 1531098000, 
    1531101600, 1531105200, 1531108800, 1531112400, 1531116000, 
    1531119600, 1531123200, 1531126800, 1531130400, 1531134000, 
    1531137600, 1531141200, 1531144800, 1531148400, 1531152000, 
    1531155600, 1531159200, 1531162800, 1531166400, 1531170000, 
    1531173600, 1531177200, 1531180800, 1531184400, 1531188000, 
    1531191600, 1531195200, 1531198800, 1531202400, 1531206000, 
    1531209600, 1531213200, 1531216800, 1531220400, 1531224000, 
    1531227600, 1531231200, 1531234800, 1531238400, 1531242000, 
    1531245600, 1531249200, 1531252800, 1531256400, 1531260000, 
    1531263600, 1531267200, 1531270800, 1531274400, 1531278000, 
    1531281600, 1531285200, 1531288800, 1531292400, 1531296000, 
    1531299600, 1531303200, 1531306800, 1531310400, 1531314000, 
    1531317600, 1531321200, 1531324800, 1531328400, 1531332000, 
    1531335600, 1531339200, 1531342800, 1531346400, 1531350000, 
    1531353600, 1531357200, 1531360800, 1531364400, 1531368000, 
    1531371600, 1531375200, 1531378800, 1531382400, 1531386000, 
    1531389600, 1531393200, 1531396800, 1531400400, 1531404000, 
    1531407600, 1531411200, 1531414800, 1531418400, 1531422000, 
    1531425600, 1531429200, 1531432800, 1531436400, 1531440000, 
    1531443600, 1531447200, 1531450800, 1531454400, 1531458000, 
    1531461600, 1531465200, 1531468800, 1531472400, 1531476000, 
    1531479600, 1531483200, 1531486800, 1531490400, 1531494000, 
    1531497600, 1531501200, 1531504800, 1531508400, 1531512000, 
    1531515600, 1531519200, 1531522800, 1531526400, 1531530000, 
    1531533600, 1531537200, 1531540800, 1531544400, 1531548000, 
    1531551600, 1531555200, 1531558800, 1531562400, 1531566000, 
    1531569600, 1531573200, 1531576800, 1531580400, 1531584000, 
    1531587600, 1531591200, 1531594800, 1531598400, 1531602000, 
    1531605600, 1531609200, 1531612800, 1531616400, 1531620000, 
    1531623600, 1531627200, 1531630800, 1531634400, 1531638000, 
    1531641600, 1531645200, 1531648800, 1531652400, 1531656000, 
    1531659600, 1531663200, 1531666800, 1531670400, 1531674000, 
    1531677600, 1531681200, 1531684800, 1531688400, 1531692000, 
    1531695600, 1531699200, 1531702800, 1531706400, 1531710000, 
    1531713600, 1531717200, 1531720800, 1531724400, 1531728000, 
    1531731600, 1531735200, 1531738800, 1531742400, 1531746000, 
    1531749600, 1531753200, 1531756800, 1531760400, 1531764000, 
    1531767600, 1531771200, 1531774800, 1531778400, 1531782000, 
    1531785600, 1531789200, 1531792800, 1531796400, 1531800000, 
    1531803600, 1531807200, 1531810800, 1531814400, 1531818000, 
    1531821600, 1531825200, 1531828800, 1531832400, 1531836000, 
    1531839600, 1531843200, 1531846800, 1531850400, 1531854000, 
    1531857600, 1531861200, 1531864800, 1531868400, 1531872000, 
    1531875600, 1531879200, 1531882800, 1531886400, 1531890000, 
    1531893600, 1531897200, 1531900800, 1531904400, 1531908000, 
    1531911600, 1531915200, 1531918800, 1531922400, 1531926000, 
    1531929600, 1531933200, 1531936800, 1531940400, 1531944000, 
    1531947600, 1531951200, 1531954800, 1531958400, 1531962000, 
    1531965600, 1531969200, 1531972800, 1531976400, 1531980000, 
    1531983600, 1531987200, 1531990800, 1531994400, 1531998000, 
    1532001600, 1532005200, 1532008800, 1532012400, 1532016000, 
    1532019600, 1532023200, 1532026800, 1532030400, 1532034000, 
    1532037600, 1532041200, 1532044800, 1532048400, 1532052000, 
    1532055600, 1532059200, 1532062800, 1532066400, 1532070000, 
    1532073600, 1532077200, 1532080800, 1532084400, 1532088000, 
    1532091600, 1532095200, 1532098800, 1532102400, 1532106000, 
    1532109600, 1532113200, 1532116800, 1532120400, 1532124000, 
    1532127600, 1532131200, 1532134800, 1532138400, 1532142000, 
    1532145600, 1532149200, 1532152800, 1532156400, 1532160000, 
    1532163600, 1532167200, 1532170800, 1532174400, 1532178000, 
    1532181600, 1532185200, 1532188800, 1532192400, 1532196000, 
    1532199600, 1532203200, 1532206800, 1532210400, 1532214000, 
    1532217600, 1532221200, 1532224800, 1532228400, 1532232000, 
    1532235600, 1532239200, 1532242800, 1532246400, 1532250000, 
    1532253600, 1532257200, 1532260800, 1532264400, 1532268000, 
    1532271600, 1532275200, 1532278800, 1532282400, 1532286000, 
    1532289600, 1532293200, 1532296800, 1532300400, 1532304000, 
    1532307600, 1532311200, 1532314800, 1532318400, 1532322000, 
    1532325600, 1532329200, 1532332800, 1532336400, 1532340000, 
    1532343600, 1532347200, 1532350800, 1532354400, 1532358000, 
    1532361600, 1532365200, 1532368800, 1532372400, 1532376000, 
    1532379600, 1532383200, 1532386800, 1532390400, 1532394000, 
    1532397600, 1532401200, 1532404800, 1532408400, 1532412000, 
    1532415600, 1532419200, 1532422800, 1532426400, 1532430000, 
    1532433600, 1532437200, 1532440800, 1532444400, 1532448000, 
    1532451600, 1532455200, 1532458800, 1532462400, 1532466000, 
    1532469600, 1532473200, 1532476800, 1532480400, 1532484000, 
    1532487600, 1532491200, 1532494800, 1532498400, 1532502000, 
    1532505600, 1532509200, 1532512800, 1532516400, 1532520000, 
    1532523600, 1532527200, 1532530800, 1532534400, 1532538000, 
    1532541600, 1532545200, 1532548800, 1532552400, 1532556000, 
    1532559600, 1532563200, 1532566800, 1532570400, 1532574000, 
    1532577600, 1532581200, 1532584800, 1532588400, 1532592000, 
    1532595600, 1532599200, 1532602800, 1532606400, 1532610000, 
    1532613600, 1532617200, 1532620800, 1532624400, 1532628000, 
    1532631600, 1532635200, 1532638800, 1532642400, 1532646000, 
    1532649600, 1532653200, 1532656800, 1532660400, 1532664000, 
    1532667600, 1532671200, 1532674800, 1532678400, 1532682000, 
    1532685600, 1532689200, 1532692800, 1532696400, 1532700000, 
    1532703600, 1532707200, 1532710800, 1532714400, 1532718000, 
    1532721600, 1532725200, 1532728800, 1532732400, 1532736000, 
    1532739600, 1532743200, 1532746800, 1532750400, 1532754000, 
    1532757600, 1532761200, 1532764800, 1532768400, 1532772000, 
    1532775600, 1532779200, 1532782800, 1532786400, 1532790000, 
    1532793600, 1532797200, 1532800800, 1532804400, 1532808000, 
    1532811600, 1532815200, 1532818800, 1532822400, 1532826000, 
    1532829600, 1532833200, 1532836800, 1532840400, 1532844000, 
    1532847600, 1532851200, 1532854800, 1532858400, 1532862000, 
    1532865600, 1532869200, 1532872800, 1532876400, 1532880000, 
    1532883600, 1532887200, 1532890800, 1532894400, 1532898000, 
    1532901600, 1532905200, 1532908800, 1532912400, 1532916000, 
    1532919600, 1532923200, 1532926800, 1532930400, 1532934000, 
    1532937600, 1532941200, 1532944800, 1532948400, 1532952000, 
    1532955600, 1532959200, 1532962800, 1532966400, 1532970000, 
    1532973600, 1532977200, 1532980800, 1532984400, 1532988000, 
    1532991600), class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
    activity = c(59L, 74L, 2683L, 4341L, 3676L, 2143L, 3890L, 
    3887L, 1299L, 1492L, 3449L, 2200L, 1563L, 4346L, 5329L, 3037L, 
    1462L, 668L, 383L, 483L, 288L, 2765L, 3354L, 1783L, 241L, 
    301L, 261L, 3683L, 4356L, 3736L, 2810L, 1841L, 3146L, 609L, 
    2998L, 4059L, 3690L, 3735L, 1343L, 2087L, 894L, 341L, 240L, 
    2113L, 1684L, 3115L, 2890L, 138L, 21L, 451L, 96L, 2918L, 
    2279L, 2282L, 4992L, 698L, 427L, 581L, 1248L, 2184L, 1980L, 
    2364L, 568L, 2477L, 525L, 433L, 974L, 501L, 760L, 67L, 297L, 
    1198L, 2L, 39L, 42L, 1182L, 1749L, 2144L, 3123L, 1170L, 1641L, 
    1112L, 1526L, 1199L, 534L, 1481L, 2388L, 2756L, 392L, 112L, 
    390L, 107L, 709L, 1122L, 1562L, 451L, 8L, 74L, 0L, 158L, 
    780L, 3118L, 3292L, 2759L, 3121L, 2051L, 2387L, 900L, 627L, 
    904L, 4283L, 3726L, 1273L, 977L, 326L, 163L, 1915L, 1073L, 
    1021L, 545L, 36L, 22L, 3L, 55L, 124L, 22L, 4093L, 2867L, 
    3649L, 2550L, 1590L, 636L, 2571L, 998L, 1066L, 2967L, 1211L, 
    51L, 1188L, 1413L, 714L, 177L, 132L, 29L, 22L, 43L, 0L, 90L, 
    1094L, 1655L, 2643L, 2108L, 2249L, 2453L, 2857L, 915L, 437L, 
    1142L, 2193L, 2993L, 1139L, 1549L, 652L, 580L, 970L, 674L, 
    211L, 206L, 167L, 63L, 1L, 786L, 617L, 1575L, 2237L, 1302L, 
    1149L, 2009L, 2234L, 1263L, 1259L, 2017L, 1641L, 2683L, 1184L, 
    449L, 65L, 956L, 1538L, 1287L, 593L, 362L, 594L, 1172L, 25L, 
    445L, 921L, 1812L, 2235L, 1153L, 422L, 1084L, 2158L, 1610L, 
    845L, 1187L, 2528L, 2161L, 976L, 19L, 747L, 570L, 576L, 19L, 
    304L, 2L, 301L, 7L, 399L, 494L, 723L, 1088L, 771L, 85L, 1338L, 
    866L, 384L, 1356L, 2862L, 3805L, 2142L, 1655L, 249L, 235L, 
    3L, 0L, 283L, 981L, 634L, 1370L, 9L, 137L, 33L, 975L, 1690L, 
    1639L, 985L, 210L, 1266L, 2135L, 2080L, 1704L, 2449L, 3133L, 
    1055L, 3222L, 1152L, 173L, 858L, 188L, 700L, 330L, 905L, 
    1232L, 1006L, 5L, 21L, 520L, 1162L, 1771L, 2463L, 1403L, 
    1353L, 1938L, 2388L, 4133L, 900L, 2660L, 3504L, 3946L, 1956L, 
    818L, 604L, 937L, 373L, 48L, 400L, 201L, 876L, 505L, 162L, 
    775L, 1567L, 896L, 1648L, 995L, 2574L, 1080L, 997L, 1881L, 
    1375L, 1283L, 2156L, 2384L, 982L, 33L, 20L, 761L, 241L, 696L, 
    133L, 915L, 623L, 918L, 48L, 523L, 721L, 1624L, 1047L, 1783L, 
    313L, 1042L, 2211L, 2430L, 1770L, 1610L, 2814L, 2460L, 1770L, 
    25L, 709L, 416L, 709L, 998L, 921L, 89L, 258L, 1242L, 75L, 
    1131L, 893L, 402L, 381L, 51L, 15L, 47L, 762L, 777L, 479L, 
    2416L, 3639L, 1991L, 202L, 1054L, 917L, 1565L, 503L, 61L, 
    44L, 2103L, 2212L, 352L, 1L, 666L, 351L, 1321L, 7L, 1010L, 
    1222L, 1080L, 1643L, 1101L, 188L, 2793L, 1548L, 1811L, 1807L, 
    51L, 788L, 1108L, 1157L, 1038L, 225L, 454L, 441L, 376L, 444L, 
    5L, 501L, 579L, 1253L, 1600L, 1051L, 498L, 2217L, 2362L, 
    2425L, 1220L, 2037L, 2684L, 799L, 471L, 139L, 545L, 1117L, 
    177L, 487L, 1420L, 692L, 303L, 736L, 750L, 1386L, 926L, 30L, 
    862L, 1912L, 2731L, 1123L, 1160L, 2892L, 1634L, 585L, 3473L, 
    2243L, 441L, 399L, 1482L, 111L, 455L, 1315L, 691L, 1428L, 
    96L, 52L, 258L, 1135L, 1727L, 448L, 2148L, 358L, 2180L, 1519L, 
    2634L, 828L, 1212L, 1052L, 2851L, 902L, 171L, 236L, 3L, 727L, 
    1366L, 637L, 43L, 0L, 1320L, 146L, 664L, 862L, 663L, 227L, 
    227L, 995L, 743L, 1793L, 2421L, 1346L, 1874L, 2182L, 1333L, 
    1967L, 1023L, 297L, 340L, 1469L, 10L, 213L, 805L, 705L, 47L, 
    605L, 257L, 1359L, 41L, 1019L, 1426L, 2219L, 1179L, 1624L, 
    537L, 421L, 1747L, 2941L, 2921L, 1046L, 283L, 476L, 218L, 
    59L, 389L, 657L, 1293L, 24L, 455L, 6L, 1232L, 2264L, 1152L, 
    600L, 11L, 980L, 1519L, 2004L, 1933L, 2161L, 1386L, 1883L, 
    2978L, 1385L, 104L, 1309L, 2L, 364L, 550L, 0L, 1433L, 1634L, 
    27L, 860L, 1095L, 1102L, 132L, 582L, 710L, 1368L, 2470L, 
    2944L, 1030L, 1286L, 387L, 2590L, 2449L, 743L, 134L, 274L, 
    205L, 360L, 627L, 1357L, 591L, 216L, 143L, 70L, 2L, 477L, 
    42L, 81L, 304L, 2827L, 2437L, 2002L, 688L, 935L, 812L, 404L, 
    1098L, 1157L, 857L, 466L, 215L, 714L, 269L, 1223L, 8L, 1L, 
    635L, 6L, 1797L, 1363L, 246L, 704L, 1089L, 943L, 2251L, 813L, 
    2643L, 1657L, 18L, 1132L, 2884L, 1044L, 149L, 1146L, 68L, 
    1227L, 1189L, 129L, 1291L, 7L, 9L, 1299L, 389L, 288L, 157L, 
    0L, 324L, 248L, 915L, 795L, 598L, 733L, 308L, 2760L, 2874L, 
    1903L, 499L, 73L, 31L, 1146L, 920L, 852L, 2L, 104L, 564L, 
    16L, 1903L, 675L, 1859L, 720L, 1017L, 4L, 2114L, 2264L, 1152L, 
    935L, 1691L, 1031L, 2568L, 2035L, 226L, 18L, 1716L, 249L, 
    717L, 635L, 919L, 1436L, 16L, 17L, 1891L, 1175L, 74L, 435L, 
    377L, 718L, 619L, 439L, 1373L, 2154L, 2481L, 763L, 2084L, 
    910L, 641L, 669L, 737L, 793L, 1471L, 12L, 96L, 6L, 13L, 81L, 
    1227L, 1685L, 260L, 238L, 575L, 930L, 330L, 1139L, 785L, 
    1110L, 1007L, 1770L, 2824L, 729L, 776L, 602L, 550L, 1432L, 
    567L, 197L, 107L, 38L, 648L, 264L, 911L, 2239L, 1063L, 9L, 
    1336L, 1235L, 628L, 1722L, 1028L, 1393L, 44L, 2110L, 1719L, 
    666L, 127L, 885L, 788L, 1274L, 765L, 1094L, 38L, 514L, 14L, 
    59L, 1081L, 1266L, 359L, 1055L, 280L, 123L, 2251L, 2302L, 
    1116L, 2750L, 764L, 1377L, 2776L, 970L, 814L, 10L, 1364L, 
    1137L, 279L, 10L, 605L, 279L, 596L, 12L, 1443L, 1463L, 1426L, 
    132L, 924L, 379L, 693L, 137L, 219L, 884L, 194L, 450L, 1204L, 
    487L, 578L, 445L, 9L, 823L, 2L, 1212L, 12L, 200L, 9L, 152L, 
    1062L, 1926L, 1156L, 1951L, 1735L, 753L, 570L, 362L, 813L, 
    756L, 1403L, 308L, 1895L, 325L, 768L, 666L, 33L, 634L, 1294L, 
    819L, 39L, 579L, 8L, 657L, 438L, 521L, 896L, 2560L, 1383L, 
    819L, 1293L, 2257L, 476L, 1850L, 759L, 2482L, 1513L, 789L, 
    78L, 329L, 43L, 50L, 1583L, 342L, 0L, 495L, 13L, 127L, 1415L, 
    1534L, 939L, 2315L, 649L, 154L, 2838L, 1462L, 2255L, 1058L, 
    316L, 1825L, 2391L, 324L, 185L, 813L, 997L, 830L, 407L, 796L, 
    624L, 1002L, 6L, 86L, 1091L, 1951L, 8L, 1863L, 2555L, 799L, 
    749L, 2386L, 1893L, 524L, 846L, 2263L, 2266L, 779L, 88L, 
    380L, 1495L, 1985L, 3L, 1462L, 1450L, 1L, 19L, 967L, 1565L, 
    1066L, 9L, 99L, 4L, 1889L, 1848L, 1924L, 471L, 1357L, 626L, 
    1465L, 1787L, 1437L, 115L, 322L, 717L, 1639L, 990L, 1029L, 
    1112L, 372L, 8L, 256L, 1679L, 1209L, 2246L, 2153L, 1762L, 
    1883L, 1551L, 998L, 728L, 1274L, 888L, 508L, 2357L, 452L, 
    1167L, 2385L, 3280L, 320L, 1130L, 878L, 583L, 799L, 4L, 61L, 
    394L, 1237L, 854L, 68L, 379L, 2910L, 3088L, 1011L, 840L, 
    1024L, 2496L, 3079L, 2830L, 1841L, 1772L, 595L, 65L, 584L, 
    2110L, 1966L, 473L, 21L, 847L, 293L, 881L, 840L, 1912L, 683L, 
    1362L, 1276L, 3131L, 3110L, 1773L, 1077L, 1437L, 769L, 2311L, 
    1623L, 562L, 42L, 1791L, 1318L, 1230L, 202L, 2630L, 1174L, 
    396L, 52L, 2261L, 1237L, 56L, 927L, 2491L, 3180L, 352L, 81L, 
    2072L, 3207L, 2394L, 600L, 3280L, 1745L, 147L, 1L, 1544L, 
    350L, 2198L, 1833L, 55L)), row.names = c(NA, -984L), class = c("data.table", 
"data.frame"), .internal.selfref = <pointer: 0x0000000002641ef0>)

其中hour是一天中从0到23的小时,date and time是时间戳,activity是一天中该小时的平均小时活动。

>

我想计算每小时的平均总活动量,最后得到一个这样的表(值已经被发明):

head(output)   
   hour        avg
1     0       7.50
2     1       6.56
3     2       7.56
4     3       6.46
5     4       4.62
6     5       3.97

很抱歉,如果帖子标题误导了我,我想不出更好的办法来总结我的问题。

感谢任何输入!

0 个答案:

没有答案