[R] Need guidance on summarizing time data

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Nov 30 17:04:02 CET 2020


Does table(DF$Time) do what you want?

Seems kinda odd to me that you want to distinguish between 18:31 and 18:32 but you don't care which days those occur on.  If your phenomenon is related to local time-of-day then perhaps you might want to correlate with sun elevation relative to the horizon. If you have lat/lon and timezone then the maptools package can estimate local sun position from datetime.

On November 30, 2020 7:48:00 AM PST, Neotropical bat risk assessments and acoustic tools <neotropical.bats using gmail.com> wrote:
>Hi all,
>
>I need to summarize temporal activity. However date\times in R seem to 
>be not easily handled.
>Seems I may need to convert date\time values to a recognizable format?
>
>My "raw data" is tab (text) includes a location ID, date and time(24 hr
>
>format).
>Format is like this:
>Location    Date    Time
>156    2/25/2008    18:31
>156    2/25/2008    18:31
>156    2/25/2008    18:32
>156    2/25/2008    18:35
>156    2/25/2008    18:38
>156    2/25/2008    18:41
>156    2/25/2008    18:42
>156    2/25/2008    18:43
>156    2/25/2008    18:43
>156    2/25/2008    18:55
>156    2/25/2008    18:56
>156    2/25/2008    18:56
>156    2/26/2008    18:35
>156    2/26/2008    18:35
>156    2/26/2008    18:35
>156    2/26/2008    18:35
>196    7/16/2006    4:47
>250    4/9/2004    18:41
>250    4/9/2004    18:44
>253    3/5/2004    18:30
>1268    2/11/2001    18:39
>1268    2/11/2001    18:39
>1344    4/17/2003    19:06
>1409    2/28/2004    5:51
>...etc. for 10,390 rows of data.
>
>I am aiming for a summary by times for all of the data such that I have
>
>total number of "events" or count for each time period. So something
>like
>
>18:31 41
>18:32 38
>
>and so on.
>
>So a "simple" count of the time occurrences.
>
>I tried to do a summary running frequencies
>descriptive.table(vars = d(Time) ,
>+ strata = d(Date),data= Active,
>+ func.names =c("Valid N","Minimum","Maximum"))
>
>
>Warning message:
>In descriptive.table(vars = d(Time), strata = d(Date), data = Active, 
>:
>   Non-numeric variables dropped from descriptive table
> > Active[,3]<-as.POSIXct(Active[,3], format='%m-%d-%y %H:%M:%S')
> > Active[,2]<-as.Date(Active[,2], format= '%m/%d/%y')
> > frequencies(Active[c("Time")] , r.digits = 1)
>Error in names(x) <- value :
>   'names' attribute [4] must be the same length as the vector [3]
>
>Suggestions welcomed.
>
>Cheers all

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list