[R-sig-eco] aggregation of data (cou8nts) by time

Bruce Miller b@t@nc@t@ @end|ng |rom gm@||@com
Sat Jun 29 19:55:40 CEST 2019


I am having an issue with trying to aggregate data by time.
I have 3+ years of bat data recorded from dusk to dawn at a fixed site, 
along with moon phase and associated weather data.

Older version of code I have for reshape/reshape2 is not working.

I need to reformat data to run GAM to see what association there may be 
between bat activity, weather (wind, rain etc.) and moon phase 
(illumination).

It has been since R 2.1 that I last tried to address this data. :-[

My data is in long format and tidy as:

Species    Date    Time
Baudub    4/7/2000    19:16
Baudub    4/7/2000    20:18
Baudub    4/7/2000    21:11
Eptfur    4/7/2000    19:12
Eptfur    4/7/2000    20:47
Eptfur    4/7/2000    20:49
Eptfur    4/7/2000    21:06
Eptfur    4/7/2000    21:36
Eptfur    4/7/2000    21:42
Eptfur    4/7/2000    21:43
Eptfur    4/7/2000    21:48
Eptfur    4/7/2000    21:48
Eptfur    4/7/2000    22:06
Eptfur    4/7/2000    22:07
Eptfur    4/7/2000    22:31
Eptfur    4/7/2000    22:32
Eptfur    4/8/2000    00:01
Lasega    4/7/2000    20:13
Mormeg    4/7/2000    20:28
Mormeg    4/7/2000    20:29
Mormeg    4/7/2000    21:26
Mormeg    4/7/2000    22:50
Mormeg    4/7/2000    22:50
Mormeg    4/7/2000    23:16
Mormeg    4/8/2000    00:03
Myoele    4/7/2000    19:32
Myoele    4/7/2000    19:33

What I have in an older database with a data tbl that is in this wide 
format:
Certainly not tidy.

  Date    Time    Sacbil    Dicalb    Ptedav    Ptepar    Pteper 
Mormeg    Lasega    Lasblo    Rhotum    Eptfur    Myoele Molmol    Molruf
1/4/2000    22:51    0    0    2    0    0    0    0    0    0 0    1    
0    0
1/4/2000    22:52    0    2    2    0    0    0    0    0    0 0    1    
0    1
1/4/2000    22:53    0    0    1    0    0    0    0    1    0 0    1    
0    0
1/4/2000    22:54    0    0    1    0    0    0    0    2    0 0    1    
0    0
1/4/2000    22:55    0    1    0    0    0    0    0    1    0 0    1    
0    0
1/4/2000    22:56    0    1    0    0    0    0    0    0    0 0    0    
0    0
1/4/2000    22:57    0    0    0    0    0    0    0    0    0 0    0    
0    0
1/4/2000    22:58    0    1    1    0    0    0    0    1    0 0    1    
0    0
1/4/2000    23:00    0    1    1    0    0    0    0    0    0 0    3    
0    0
1/4/2000    23:02    0    2    1    0    0    0    0    1    0 0    2    
0    0
1/4/2000    23:04    0    0    4    0    0    0    0    0    0 0    2    
0    0
1/4/2000    23:05    0    1    2    0    0    0    0    1    0 0    1    
0    0
1/4/2000    23:07    0    0    1    0    0    0    0    1    1 0    1    
0    0
1/4/2000    23:08    0    0    1    0    0    0    0    1    0 0    1    
0    0
1/4/2000    23:09    0    0    1    0    0    0    0    0    0 0    2    
0    0
1/4/2000    23:11    0    0    1    0    0    0    0    0    0 0    1    
0    0
1/4/2000    23:12    0    0    0    0    0    0    0    0    0 0    1    
0    0
1/4/2000    23:16    0    0    1    0    0    0    0    2    0 0    2    
0    0
1/4/2000    23:17    0    0    2    0    0    0    0    2    0 0    3    
0    0
1/4/2000    23:18    0    0    5    0    0    0    0    0    0 0    2    
0    0
1/4/2000    23:19    0    0    3    0    0    0    0    0    0 0    5    
0    0


I assume I need to aggregate the data so I have a count of occurrences 
by time.

Melt works fine but can not seem to obtain a count of times a bat was 
detected for each date/time interval.

I have read on-line about tidyr and apparently this has replaced 
reshape2 etc.  What I have tried has not been useful so far.

Or perhaps I can/should start a fresh new analysis with new packages and 
a different approach.
Currently I am unsure of what direction to take evaluate species 
specific activity to weather data and moon phase/illumination with all 
linked to specific date/times.

Any suggestions appreciated.

Cheers,
Bruce

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list