[R] Need guidance on summarizing time data

Thierry Onkelinx th|erry@onke||nx @end|ng |rom |nbo@be
Mon Nov 30 17:01:45 CET 2020


Dear Bruce,

I think this should be straightforward with tidyverse. If not please
provide a small reproducible data set with dput().

library(tidyverse)
count(Active, Time)
count(Active, Date, Time)

Best regards,

ir. Thierry Onkelinx
Statisticus / Statistician

Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
www.inbo.be

///////////////////////////////////////////////////////////////////////////////////////////
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
///////////////////////////////////////////////////////////////////////////////////////////

<https://www.inbo.be>


Op ma 30 nov. 2020 om 16:48 schreef Neotropical bat risk assessments and
acoustic tools <neotropical.bats using gmail.com>:

> 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
>
> --
> Bruce W. Miller, PhD.
> Neotropical bat risk and acoustic assessments
> Conservation Fellow - Wildlife Conservation Society
> Research Associate, American Museum of Natural History
>
> If we lose the bats, we may lose much of the tropical vegetation and the
> lungs of the planet
>
> Using acoustic sampling to identify and map species distributions
> and pioneering acoustic tools for ecology and conservation of bats for >25
> years.
>
> Key projects include providing free interactive identification keys and
> call fact sheets for the vocal signatures of New World Bats
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list