What is best way to calculate % of time?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

What is best way to calculate % of time?

Bat Dude
Hi all,

It seems R has gotten better/more packages in dealing with time data.

I want to create "simple" summaries of time for bat activity.
Data is all in an Access relational database and exported as a CSV file
with 4 columns in this format:
Species = a 6 letter code or "Buzz" to indicated when bats are feeding
Location = a 4 digit number
Date= MMDDYYYY
Time=HH:MM (24 hr format)

Species    Location    Date    Time
Buzz    7716    1/25/2000    0:05
Buzz    7716    1/25/2000    0:05
Buzz    7716    1/25/2000    0:05
Buzz    7716    1/25/2000    0:47
Buzz    7716    1/25/2000    0:47
Buzz    7716    1/25/2000    0:47
Buzz    7716    1/25/2000    0:47
Buzz    7717    7/3/2000    20:17
Buzz    7717    7/3/2000    20:17
Buzz    7717    7/3/2000    20:17
Buzz    7717    7/3/2000    20:17
Buzz    7717    7/3/2000    20:30
Buzz    7717    7/3/2000    20:30
Buzz    7717    7/3/2000    20:30
Buzz    7717    7/3/2000    20:30
Ptedav    7717    7/3/2000    20:14
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:17
Ptedav    7717    7/3/2000    20:17
Ptedav    7717    7/3/2000    20:17
Ptedav    7717    7/3/2000    20:18
Ptedav    7717    7/3/2000    20:18
Ptedav    7717    7/3/2000    20:18
Ptedav    7717    7/3/2000    20:18
Ptedav    7717    7/3/2000    20:18
Ptemes    7717    7/3/2000    23:15
Ptemes    7717    7/3/2000    23:21
Ptemes    7717    7/3/2000    23:22
Ptemes    7717    7/3/2000    23:23
Ptemes    7717    7/3/2000    23:25
Ptemes    7717    7/3/2000    23:26
Ptemes    7717    7/3/2000    23:27
Ptemes    7717    7/3/2000    23:28
Ptemes    7717    7/3/2000    23:29
Ptemes    7717    7/3/2000    23:33
Ptemes    7717    7/3/2000    23:35
Ptemes    7717    7/3/2000    23:36
Ptemes    7717    7/3/2000    23:37

The above is clearly not a complete DF but only a format sample. Data
begins when the first bat was recorded and ends when the last bat was
recorded.  So all are times from sunset to sunrise.  Dates roll over so
for example one night of data would begin at 18:00 1/1/2000 and end
06:00 1/2/2000.

What I need to do is have a summary of Buzz events (feeding) and
calculate the percentage of total time bats were active and have a
summary of time feeding buzz was recorded and total bat activity to
determine what percentage of time was spent with feeding attempts over
the active period.

This by all bats by survey night and by single species by survey night.
Any suggestions welcomed.

Happy holidays all


--
Bruce W. Miller, PhD.
Neotropical bat risk assessments
Conservation Fellow - Wildlife Conservation Society

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

John Kane-3
I am sorry but I am at a loss here.
According to your sample data you have 3 Species : Buzz,  Ptedav,
Ptemes, but you say that "Buzz" indicates that the bat is feeding.
What has that to do with feeding?

Assuming Buzz is feeding activity, are all incidents of feeding
activity a single point in time?

Likewise the data has multiple entries such as
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15
Ptedav    7717    7/3/2000    20:15

What does that represent?


On Wed, 25 Dec 2019 at 07:29, Neotropical bat risk assessments
<[hidden email]> wrote:

>
> Hi all,
>
> It seems R has gotten better/more packages in dealing with time data.
>
> I want to create "simple" summaries of time for bat activity.
> Data is all in an Access relational database and exported as a CSV file
> with 4 columns in this format:
> Species = a 6 letter code or "Buzz" to indicated when bats are feeding
> Location = a 4 digit number
> Date= MMDDYYYY
> Time=HH:MM (24 hr format)
>
> Species    Location    Date    Time
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Ptedav    7717    7/3/2000    20:14
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptemes    7717    7/3/2000    23:15
> Ptemes    7717    7/3/2000    23:21
> Ptemes    7717    7/3/2000    23:22
> Ptemes    7717    7/3/2000    23:23
> Ptemes    7717    7/3/2000    23:25
> Ptemes    7717    7/3/2000    23:26
> Ptemes    7717    7/3/2000    23:27
> Ptemes    7717    7/3/2000    23:28
> Ptemes    7717    7/3/2000    23:29
> Ptemes    7717    7/3/2000    23:33
> Ptemes    7717    7/3/2000    23:35
> Ptemes    7717    7/3/2000    23:36
> Ptemes    7717    7/3/2000    23:37
>
> The above is clearly not a complete DF but only a format sample. Data
> begins when the first bat was recorded and ends when the last bat was
> recorded.  So all are times from sunset to sunrise.  Dates roll over so
> for example one night of data would begin at 18:00 1/1/2000 and end
> 06:00 1/2/2000.
>
> What I need to do is have a summary of Buzz events (feeding) and
> calculate the percentage of total time bats were active and have a
> summary of time feeding buzz was recorded and total bat activity to
> determine what percentage of time was spent with feeding attempts over
> the active period.
>
> This by all bats by survey night and by single species by survey night.
> Any suggestions welcomed.
>
> Happy holidays all
>
>
> --
> Bruce W. Miller, PhD.
> Neotropical bat risk assessments
> Conservation Fellow - Wildlife Conservation Society
>
> 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
>
> ______________________________________________
> [hidden email] 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.



--
John Kane
Kingston ON Canada

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

John Kane-3
Hi Bruce,
You replied just to me. I have taken the liberty of cc:ing R-help as there
lots of more knowledgeable people than me there who may be able to help.
In the meantime I remain confused.
Here is my impression of the sample data that you supplied. I have combined
Date & Time into a single POSIXct variable, dtime. Just paste it into
<b>R</b>
##===============================================================##
dat2 <- structure(list(Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label =
c("Buzz", "Ptedav", "Ptemes"), class = "factor"), Location = c(7716L,
7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7717L, 7717L, 7717L, 7717L,
7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
7717L), dtime = structure(c(948758700, 948758700, 948758700, 948761220,
948761220, 948761220, 948761220, 962655420, 962655420, 962655420,
962655420, 962656200, 962656200, 962656200, 962656200, 962655240,
962655300, 962655300, 962655300, 962655300, 962655300, 962655420,
962655420, 962655420, 962655480, 962655480, 962655480, 962655480,
962655480, 962666100, 962666460, 962666520, 962666580, 962666700,
962666760, 962666820, 962666880, 962666940, 962667180, 962667300,
962667360, 962667420), class = c("POSIXct", "POSIXt"), tzone = "UTC")),
class = "data.frame", row.names = c(NA, -42L))
##===============================================================##
<b>The 6 letter species codes relate to individual bat species and the Buzz
= Feeding buzz that indicates a feeding attempt by a given bat. So the
"codes" are both species and information on the call type.</b>
But, at the moment you have two variables in the one column, Species: The
type of bat and feeding behaviour.
<b>The date/time is when the species was recorded and is linked to the
location.</b>
Okay. Will this give us a unique key?
<b>Therefore to run the summary stats I need I will need to remove the
duplicate times that are rounded to the minute</b>
What duplicate times? Where are they? When are they rounded?
I have never used Access. Will it produce a data dictionary? Can it export
a small subset of the relevant data to another Access DB, some other DB or
in .csv format? At the moment I just cannot visualize what your data layout
looks like.
Can you point us to any documentation that explains what information in
being gathered—preferably in simple–minded English?

On Wed, 25 Dec 2019 at 12:08, Neotropical bat risk assessments <
[hidden email]> wrote:

> Hi John,
>
> Likely TMI but....
>
> The example was only to show the data format, clearly not the entire data
> set. ;-)
> Analyses will be by locations, dates and species in any case so small
> subsets.
>
> My master relational database has >1.9 million records.  These are
> acoustic data recordings of bats and includes data fro >425 species.
>
> The 6 letter species codes relate to individual bat species and the Buzz =
> Feeding buzz that indicates a feeding attempt by a given bat.  So the
> "codes" are both species and information on the call type.
>
> So yes, if a call includes a feeding buzz it is noted as Buzz in addition
> to the species ID codes..
> A given 15 second acoustic recording may have up to 5 species recorded and
> when imported into the relational DB each individual species is parsed into
> its own record as well as records of call notes e.g. Buzz.
>
> The date/time is when the species was recorded and is linked to the
> location.
> Although the call data summary below is summarized by *minute* the actual
> data is recorded by time which includes seconds in addition to minutes.
> So there could be say 3+ files recorded during the same minute but at
> different time periods as seconds (0-59) are included.
>
> Therefore to run the summary stats I need I will need to remove the
> duplicate times that are rounded to the minute.
>
> Again tnx for taking time to reply.
>
> Cheers,
>
> Bruce
>
> I am sorry but I am at a loss here.
> According to your sample data you have 3 Species : Buzz,  Ptedav,
> Ptemes, but you say that "Buzz" indicates that the bat is feeding.
> What has that to do with feeding?
>
> Assuming Buzz is feeding activity, are all incidents of feeding
> activity a single point in time?
>
> Likewise the data has multiple entries such as
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
>
> What does that represent?
>
>
> On Wed, 25 Dec 2019 at 07:29, Neotropical bat risk assessments<[hidden email]> <[hidden email]> wrote:
>
> Hi all,
>
> It seems R has gotten better/more packages in dealing with time data.
>
> I want to create "simple" summaries of time for bat activity.
> Data is all in an Access relational database and exported as a CSV file
> with 4 columns in this format:
> Species = a 6 letter code or "Buzz" to indicated when bats are feeding
> Location = a 4 digit number
> Date= MMDDYYYY
> Time=HH:MM (24 hr format)
>
> Species    Location    Date    Time
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:05
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7716    1/25/2000    0:47
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:17
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Buzz    7717    7/3/2000    20:30
> Ptedav    7717    7/3/2000    20:14
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:15
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:17
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptedav    7717    7/3/2000    20:18
> Ptemes    7717    7/3/2000    23:15
> Ptemes    7717    7/3/2000    23:21
> Ptemes    7717    7/3/2000    23:22
> Ptemes    7717    7/3/2000    23:23
> Ptemes    7717    7/3/2000    23:25
> Ptemes    7717    7/3/2000    23:26
> Ptemes    7717    7/3/2000    23:27
> Ptemes    7717    7/3/2000    23:28
> Ptemes    7717    7/3/2000    23:29
> Ptemes    7717    7/3/2000    23:33
> Ptemes    7717    7/3/2000    23:35
> Ptemes    7717    7/3/2000    23:36
> Ptemes    7717    7/3/2000    23:37
>
> The above is clearly not a complete DF but only a format sample. Data
> begins when the first bat was recorded and ends when the last bat was
> recorded.  So all are times from sunset to sunrise.  Dates roll over so
> for example one night of data would begin at 18:00 1/1/2000 and end
> 06:00 1/2/2000.
>
> What I need to do is have a summary of Buzz events (feeding) and
> calculate the percentage of total time bats were active and have a
> summary of time feeding buzz was recorded and total bat activity to
> determine what percentage of time was spent with feeding attempts over
> the active period.
>
> This by all bats by survey night and by single species by survey night.
> Any suggestions welcomed.
>
> Happy holidays all
>
>
> --
> Bruce W. Miller, PhD.
> Neotropical bat risk assessments
> Conservation Fellow - Wildlife Conservation Society
>
> 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
>
> [hidden email] mailing list -- To UNSUBSCRIBE and more, seehttps://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.
>
> --
> John Kane
> Kingston ON Canada
>
>
>
> --
> Bruce W. Miller, PhD.
> Neotropical bat risk assessments
> Conservation Fellow - Wildlife Conservation Society
>
> 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
>
>
>

--
John Kane
Kingston ON Canada

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

Bat Dude
Tnx John,
Yep failed to "reply all" my bad.

Yes the mix of "information" on call type and species are in the same
field.  It will be a single mouse click to export only the "buzz" data
from the master DB as a separate CSV file from the species data. So this
could be a new DF/data set for R.
This is due to the legacy issues of how the acoustic data are added to
the metadata of the bat call recordings.
Combining date and times does not provide for sampling nights that roll
over after midnight.

I may need to reread Hadley's Tidy Data manifesto re: data handling ;-).

The location, date and time does provide unique variables.
Duplicate times mentioned are the "duplicated" values you noted. This
happens as the actual call files include seconds for a more precise time
when the recordings were made.  Rounding to nearest minute suffices for
a summary of total minutes spent  with "feeding attempts" vs total
active time.

The data being gathered is reviewed in a purpose build bat acoustic
software program when reviewing bat call files.  The metadata include
the "Who", "Where" & "When" recorded. What is added to this as the
acoustic files are reviewed are information on call types and species IDs.

This metadata is exported as a TXT file and imported into a master
Access DB I developed over the past 15 years to manage "BIG DATA" as
they say.  As a note I currently it have >1.9 million acoustic call
records store in the relational DB.

The data output/exported from the DB is sufficient to provide wonderful
temporal activity plots using GGplot2.  Original code for this was
developed with huge assistance from Hadley eons ago and updated to more
recent R releases and packages by a few others.

The graphics are great to visualize temporal activity but do not provide
a simple summary of amount of time spent "foraging AKA feeding buzz
data" vs total activity time for each species.

Perhaps this is /was not a simple question on how to summarize time data
to derive a % of each category, be it "buzz" or species.

Tnx again,
Bruce


>
> Hi Bruce,
> You replied just to me. I have taken the liberty of cc:ing R-help as
> there lots of more knowledgeable people than me there who may be able
> to help.
> In the meantime I remain confused.
> Here is my impression of the sample data that you supplied. I have
> combined Date & Time into a single POSIXct variable, dtime. Just paste
> it into <b>R</b>
> ##===============================================================##
> dat2 <- structure(list(Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
> 3L, 3L), .Label = c("Buzz", "Ptedav", "Ptemes"), class = "factor"),
> Location = c(7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7717L,
> 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> 7717L, 7717L, 7717L, 7717L), dtime = structure(c(948758700, 948758700,
> 948758700, 948761220, 948761220, 948761220, 948761220, 962655420,
> 962655420, 962655420, 962655420, 962656200, 962656200, 962656200,
> 962656200, 962655240, 962655300, 962655300, 962655300, 962655300,
> 962655300, 962655420, 962655420, 962655420, 962655480, 962655480,
> 962655480, 962655480, 962655480, 962666100, 962666460, 962666520,
> 962666580, 962666700, 962666760, 962666820, 962666880, 962666940,
> 962667180, 962667300, 962667360, 962667420), class = c("POSIXct",
> "POSIXt"), tzone = "UTC")), class = "data.frame", row.names = c(NA, -42L))
> ##===============================================================##
> <b>The 6 letter species codes relate to individual bat species and the
> Buzz = Feeding buzz that indicates a feeding attempt by a given bat.
> So the "codes" are both species and information on the call type.</b>
> But, at the moment you have two variables in the one column, Species:
> The type of bat and feeding behaviour.
> <b>The date/time is when the species was recorded and is linked to the
> location.</b>
> Okay. Will this give us a unique key?
> <b>Therefore to run the summary stats I need I will need to remove the
> duplicate times that are rounded to the minute</b>
> What duplicate times? Where are they? When are they rounded?
> I have never used Access. Will it produce a data dictionary? Can it
> export a small subset of the relevant data to another Access DB, some
> other DB or in .csv format? At the moment I just cannot visualize what
> your data layout looks like.
> Can you point us to any documentation that explains what information
> in being gathered—preferably in simple–minded English?
>
> On Wed, 25 Dec 2019 at 12:08, Neotropical bat risk assessments
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi John,
>
>     Likely TMI but....
>
>     The example was only to show the data format, clearly not the
>     entire data set. ;-)
>     Analyses will be by locations, dates and species in any case so
>     small subsets.
>
>     My master relational database has >1.9 million records.  These are
>     acoustic data recordings of bats and includes data fro >425 species.
>
>     The 6 letter species codes relate to individual bat species and
>     the Buzz = Feeding buzz that indicates a feeding attempt by a
>     given bat.  So the "codes" are both species and information on the
>     call type.
>
>     So yes, if a call includes a feeding buzz it is noted as Buzz in
>     addition to the species ID codes..
>     A given 15 second acoustic recording may have up to 5 species
>     recorded and when imported into the relational DB each individual
>     species is parsed into its own record as well as records of call
>     notes e.g. Buzz.
>
>     The date/time is when the species was recorded and is linked to
>     the location.
>     Although the call data summary below is summarized by *minute* the
>     actual data is recorded by time which includes seconds in addition
>     to minutes.
>     So there could be say 3+ files recorded during the same minute but
>     at different time periods as seconds (0-59) are included.
>
>     Therefore to run the summary stats I need I will need to remove
>     the duplicate times that are rounded to the minute.
>
>     Again tnx for taking time to reply.
>
>     Cheers,
>
>     Bruce
>>     I am sorry but I am at a loss here.
>>     According to your sample data you have 3 Species : Buzz,  Ptedav,
>>     Ptemes, but you say that "Buzz" indicates that the bat is feeding.
>>     What has that to do with feeding?
>>
>>     Assuming Buzz is feeding activity, are all incidents of feeding
>>     activity a single point in time?
>>
>>     Likewise the data has multiple entries such as
>>     Ptedav    7717    7/3/2000    20:15
>>     Ptedav    7717    7/3/2000    20:15
>>     Ptedav    7717    7/3/2000    20:15
>>     Ptedav    7717    7/3/2000    20:15
>>
>>     What does that represent?
>>
>>
>>     On Wed, 25 Dec 2019 at 07:29, Neotropical bat risk assessments
>>     <[hidden email]>  <mailto:[hidden email]>  wrote:
>>>     Hi all,
>>>
>>>     It seems R has gotten better/more packages in dealing with time data.
>>>
>>>     I want to create "simple" summaries of time for bat activity.
>>>     Data is all in an Access relational database and exported as a CSV file
>>>     with 4 columns in this format:
>>>     Species = a 6 letter code or "Buzz" to indicated when bats are feeding
>>>     Location = a 4 digit number
>>>     Date= MMDDYYYY
>>>     Time=HH:MM (24 hr format)
>>>
>>>     Species    Location    Date    Time
>>>     Buzz    7716    1/25/2000    0:05
>>>     Buzz    7716    1/25/2000    0:05
>>>     Buzz    7716    1/25/2000    0:05
>>>     Buzz    7716    1/25/2000    0:47
>>>     Buzz    7716    1/25/2000    0:47
>>>     Buzz    7716    1/25/2000    0:47
>>>     Buzz    7716    1/25/2000    0:47
>>>     Buzz    7717    7/3/2000    20:17
>>>     Buzz    7717    7/3/2000    20:17
>>>     Buzz    7717    7/3/2000    20:17
>>>     Buzz    7717    7/3/2000    20:17
>>>     Buzz    7717    7/3/2000    20:30
>>>     Buzz    7717    7/3/2000    20:30
>>>     Buzz    7717    7/3/2000    20:30
>>>     Buzz    7717    7/3/2000    20:30
>>>     Ptedav    7717    7/3/2000    20:14
>>>     Ptedav    7717    7/3/2000    20:15
>>>     Ptedav    7717    7/3/2000    20:15
>>>     Ptedav    7717    7/3/2000    20:15
>>>     Ptedav    7717    7/3/2000    20:15
>>>     Ptedav    7717    7/3/2000    20:15
>>>     Ptedav    7717    7/3/2000    20:17
>>>     Ptedav    7717    7/3/2000    20:17
>>>     Ptedav    7717    7/3/2000    20:17
>>>     Ptedav    7717    7/3/2000    20:18
>>>     Ptedav    7717    7/3/2000    20:18
>>>     Ptedav    7717    7/3/2000    20:18
>>>     Ptedav    7717    7/3/2000    20:18
>>>     Ptedav    7717    7/3/2000    20:18
>>>     Ptemes    7717    7/3/2000    23:15
>>>     Ptemes    7717    7/3/2000    23:21
>>>     Ptemes    7717    7/3/2000    23:22
>>>     Ptemes    7717    7/3/2000    23:23
>>>     Ptemes    7717    7/3/2000    23:25
>>>     Ptemes    7717    7/3/2000    23:26
>>>     Ptemes    7717    7/3/2000    23:27
>>>     Ptemes    7717    7/3/2000    23:28
>>>     Ptemes    7717    7/3/2000    23:29
>>>     Ptemes    7717    7/3/2000    23:33
>>>     Ptemes    7717    7/3/2000    23:35
>>>     Ptemes    7717    7/3/2000    23:36
>>>     Ptemes    7717    7/3/2000    23:37
>>>
>>>     The above is clearly not a complete DF but only a format sample. Data
>>>     begins when the first bat was recorded and ends when the last bat was
>>>     recorded.  So all are times from sunset to sunrise.  Dates roll over so
>>>     for example one night of data would begin at 18:00 1/1/2000 and end
>>>     06:00 1/2/2000.
>>>
>>>     What I need to do is have a summary of Buzz events (feeding) and
>>>     calculate the percentage of total time bats were active and have a
>>>     summary of time feeding buzz was recorded and total bat activity to
>>>     determine what percentage of time was spent with feeding attempts over
>>>     the active period.
>>>
>>>     This by all bats by survey night and by single species by survey night.
>>>     Any suggestions welcomed.
>>>
>>>     Happy holidays all
>>>
>>>
>>>     --
>>>     Bruce W. Miller, PhD.
>>>     Neotropical bat risk assessments
>>>     Conservation Fellow - Wildlife Conservation Society
>>>
>>>     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
>>>
>>>     ______________________________________________
>>>     [hidden email]  <mailto:[hidden email]>  mailing list -- To UNSUBSCRIBE and more, see
>>>     https://stat.ethz.ch/mailman/listinfo/r-help
>>>     PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>>>     and provide commented, minimal, self-contained, reproducible code.
>>     --
>>     John Kane
>>     Kingston ON Canada
>
>
>     --
>     Bruce W. Miller, PhD.
>     Neotropical bat risk assessments
>     Conservation Fellow - Wildlife Conservation Society
>
>     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
>
>
>
> --
> John Kane
> Kingston ON Canada


--
Bruce W. Miller, PhD.
Neotropical bat risk assessments
Conservation Fellow - Wildlife Conservation Society

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


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

Bert Gunter-2
I will not get into your explanation of details that, like John, I find
opaque. Please DO read Hadley's manifesto, as it appears that you need to
organize your data more appropriately.

AFAICS, however, strictly speaking your data cannot answer the question you
have posed. **Strictly speaking** to know the proportion of active time
bats spend feeding, **for each bat** you would need to know when it is
active and when it is feeding during that time. You could then summarize
this for all bats (e.g. take the average or median proportion) in a species
or whatever. As you cannot identify individual bats in your data, you
cannot do this -- i.e. you cannot answer your question.

So the question then becomes: precisely **how** exactly do you propose
using the data you have to determine when a *group* of bats are active and
when they are feeding? How are the groups explicitly identified and how are
their times active and feeding determined? In short, you need to have
information that is something like:

Bat.Group   date   active.time.start  active.time.end  feeding.time.start
feeding.time.end

( for a given date and bat group, there may be many multiple entries;
perhaps for a given group, date, and active time start and end, several
feeding time start/stop entries ( I have no idea how bats behave)).

Until you can expicitly explain how your data can generate such
information, I think it will be difficult/impossible to help you.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Dec 25, 2019 at 1:52 PM Neotropical bat risk assessments <
[hidden email]> wrote:

> Tnx John,
> Yep failed to "reply all" my bad.
>
> Yes the mix of "information" on call type and species are in the same
> field.  It will be a single mouse click to export only the "buzz" data
> from the master DB as a separate CSV file from the species data. So this
> could be a new DF/data set for R.
> This is due to the legacy issues of how the acoustic data are added to
> the metadata of the bat call recordings.
> Combining date and times does not provide for sampling nights that roll
> over after midnight.
>
> I may need to reread Hadley's Tidy Data manifesto re: data handling ;-).
>
> The location, date and time does provide unique variables.
> Duplicate times mentioned are the "duplicated" values you noted. This
> happens as the actual call files include seconds for a more precise time
> when the recordings were made.  Rounding to nearest minute suffices for
> a summary of total minutes spent  with "feeding attempts" vs total
> active time.
>
> The data being gathered is reviewed in a purpose build bat acoustic
> software program when reviewing bat call files.  The metadata include
> the "Who", "Where" & "When" recorded. What is added to this as the
> acoustic files are reviewed are information on call types and species IDs.
>
> This metadata is exported as a TXT file and imported into a master
> Access DB I developed over the past 15 years to manage "BIG DATA" as
> they say.  As a note I currently it have >1.9 million acoustic call
> records store in the relational DB.
>
> The data output/exported from the DB is sufficient to provide wonderful
> temporal activity plots using GGplot2.  Original code for this was
> developed with huge assistance from Hadley eons ago and updated to more
> recent R releases and packages by a few others.
>
> The graphics are great to visualize temporal activity but do not provide
> a simple summary of amount of time spent "foraging AKA feeding buzz
> data" vs total activity time for each species.
>
> Perhaps this is /was not a simple question on how to summarize time data
> to derive a % of each category, be it "buzz" or species.
>
> Tnx again,
> Bruce
>
>
> >
> > Hi Bruce,
> > You replied just to me. I have taken the liberty of cc:ing R-help as
> > there lots of more knowledgeable people than me there who may be able
> > to help.
> > In the meantime I remain confused.
> > Here is my impression of the sample data that you supplied. I have
> > combined Date & Time into a single POSIXct variable, dtime. Just paste
> > it into <b>R</b>
> > ##===============================================================##
> > dat2 <- structure(list(Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
> > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
> > 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
> > 3L, 3L), .Label = c("Buzz", "Ptedav", "Ptemes"), class = "factor"),
> > Location = c(7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7717L,
> > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L,
> > 7717L, 7717L, 7717L, 7717L), dtime = structure(c(948758700, 948758700,
> > 948758700, 948761220, 948761220, 948761220, 948761220, 962655420,
> > 962655420, 962655420, 962655420, 962656200, 962656200, 962656200,
> > 962656200, 962655240, 962655300, 962655300, 962655300, 962655300,
> > 962655300, 962655420, 962655420, 962655420, 962655480, 962655480,
> > 962655480, 962655480, 962655480, 962666100, 962666460, 962666520,
> > 962666580, 962666700, 962666760, 962666820, 962666880, 962666940,
> > 962667180, 962667300, 962667360, 962667420), class = c("POSIXct",
> > "POSIXt"), tzone = "UTC")), class = "data.frame", row.names = c(NA,
> -42L))
> > ##===============================================================##
> > <b>The 6 letter species codes relate to individual bat species and the
> > Buzz = Feeding buzz that indicates a feeding attempt by a given bat.
> > So the "codes" are both species and information on the call type.</b>
> > But, at the moment you have two variables in the one column, Species:
> > The type of bat and feeding behaviour.
> > <b>The date/time is when the species was recorded and is linked to the
> > location.</b>
> > Okay. Will this give us a unique key?
> > <b>Therefore to run the summary stats I need I will need to remove the
> > duplicate times that are rounded to the minute</b>
> > What duplicate times? Where are they? When are they rounded?
> > I have never used Access. Will it produce a data dictionary? Can it
> > export a small subset of the relevant data to another Access DB, some
> > other DB or in .csv format? At the moment I just cannot visualize what
> > your data layout looks like.
> > Can you point us to any documentation that explains what information
> > in being gathered—preferably in simple–minded English?
> >
> > On Wed, 25 Dec 2019 at 12:08, Neotropical bat risk assessments
> > <[hidden email] <mailto:[hidden email]>> wrote:
> >
> >     Hi John,
> >
> >     Likely TMI but....
> >
> >     The example was only to show the data format, clearly not the
> >     entire data set. ;-)
> >     Analyses will be by locations, dates and species in any case so
> >     small subsets.
> >
> >     My master relational database has >1.9 million records.  These are
> >     acoustic data recordings of bats and includes data fro >425 species.
> >
> >     The 6 letter species codes relate to individual bat species and
> >     the Buzz = Feeding buzz that indicates a feeding attempt by a
> >     given bat.  So the "codes" are both species and information on the
> >     call type.
> >
> >     So yes, if a call includes a feeding buzz it is noted as Buzz in
> >     addition to the species ID codes..
> >     A given 15 second acoustic recording may have up to 5 species
> >     recorded and when imported into the relational DB each individual
> >     species is parsed into its own record as well as records of call
> >     notes e.g. Buzz.
> >
> >     The date/time is when the species was recorded and is linked to
> >     the location.
> >     Although the call data summary below is summarized by *minute* the
> >     actual data is recorded by time which includes seconds in addition
> >     to minutes.
> >     So there could be say 3+ files recorded during the same minute but
> >     at different time periods as seconds (0-59) are included.
> >
> >     Therefore to run the summary stats I need I will need to remove
> >     the duplicate times that are rounded to the minute.
> >
> >     Again tnx for taking time to reply.
> >
> >     Cheers,
> >
> >     Bruce
> >>     I am sorry but I am at a loss here.
> >>     According to your sample data you have 3 Species : Buzz,  Ptedav,
> >>     Ptemes, but you say that "Buzz" indicates that the bat is feeding.
> >>     What has that to do with feeding?
> >>
> >>     Assuming Buzz is feeding activity, are all incidents of feeding
> >>     activity a single point in time?
> >>
> >>     Likewise the data has multiple entries such as
> >>     Ptedav    7717    7/3/2000    20:15
> >>     Ptedav    7717    7/3/2000    20:15
> >>     Ptedav    7717    7/3/2000    20:15
> >>     Ptedav    7717    7/3/2000    20:15
> >>
> >>     What does that represent?
> >>
> >>
> >>     On Wed, 25 Dec 2019 at 07:29, Neotropical bat risk assessments
> >>     <[hidden email]>  <mailto:[hidden email]>
> wrote:
> >>>     Hi all,
> >>>
> >>>     It seems R has gotten better/more packages in dealing with time
> data.
> >>>
> >>>     I want to create "simple" summaries of time for bat activity.
> >>>     Data is all in an Access relational database and exported as a CSV
> file
> >>>     with 4 columns in this format:
> >>>     Species = a 6 letter code or "Buzz" to indicated when bats are
> feeding
> >>>     Location = a 4 digit number
> >>>     Date= MMDDYYYY
> >>>     Time=HH:MM (24 hr format)
> >>>
> >>>     Species    Location    Date    Time
> >>>     Buzz    7716    1/25/2000    0:05
> >>>     Buzz    7716    1/25/2000    0:05
> >>>     Buzz    7716    1/25/2000    0:05
> >>>     Buzz    7716    1/25/2000    0:47
> >>>     Buzz    7716    1/25/2000    0:47
> >>>     Buzz    7716    1/25/2000    0:47
> >>>     Buzz    7716    1/25/2000    0:47
> >>>     Buzz    7717    7/3/2000    20:17
> >>>     Buzz    7717    7/3/2000    20:17
> >>>     Buzz    7717    7/3/2000    20:17
> >>>     Buzz    7717    7/3/2000    20:17
> >>>     Buzz    7717    7/3/2000    20:30
> >>>     Buzz    7717    7/3/2000    20:30
> >>>     Buzz    7717    7/3/2000    20:30
> >>>     Buzz    7717    7/3/2000    20:30
> >>>     Ptedav    7717    7/3/2000    20:14
> >>>     Ptedav    7717    7/3/2000    20:15
> >>>     Ptedav    7717    7/3/2000    20:15
> >>>     Ptedav    7717    7/3/2000    20:15
> >>>     Ptedav    7717    7/3/2000    20:15
> >>>     Ptedav    7717    7/3/2000    20:15
> >>>     Ptedav    7717    7/3/2000    20:17
> >>>     Ptedav    7717    7/3/2000    20:17
> >>>     Ptedav    7717    7/3/2000    20:17
> >>>     Ptedav    7717    7/3/2000    20:18
> >>>     Ptedav    7717    7/3/2000    20:18
> >>>     Ptedav    7717    7/3/2000    20:18
> >>>     Ptedav    7717    7/3/2000    20:18
> >>>     Ptedav    7717    7/3/2000    20:18
> >>>     Ptemes    7717    7/3/2000    23:15
> >>>     Ptemes    7717    7/3/2000    23:21
> >>>     Ptemes    7717    7/3/2000    23:22
> >>>     Ptemes    7717    7/3/2000    23:23
> >>>     Ptemes    7717    7/3/2000    23:25
> >>>     Ptemes    7717    7/3/2000    23:26
> >>>     Ptemes    7717    7/3/2000    23:27
> >>>     Ptemes    7717    7/3/2000    23:28
> >>>     Ptemes    7717    7/3/2000    23:29
> >>>     Ptemes    7717    7/3/2000    23:33
> >>>     Ptemes    7717    7/3/2000    23:35
> >>>     Ptemes    7717    7/3/2000    23:36
> >>>     Ptemes    7717    7/3/2000    23:37
> >>>
> >>>     The above is clearly not a complete DF but only a format sample.
> Data
> >>>     begins when the first bat was recorded and ends when the last bat
> was
> >>>     recorded.  So all are times from sunset to sunrise.  Dates roll
> over so
> >>>     for example one night of data would begin at 18:00 1/1/2000 and end
> >>>     06:00 1/2/2000.
> >>>
> >>>     What I need to do is have a summary of Buzz events (feeding) and
> >>>     calculate the percentage of total time bats were active and have a
> >>>     summary of time feeding buzz was recorded and total bat activity to
> >>>     determine what percentage of time was spent with feeding attempts
> over
> >>>     the active period.
> >>>
> >>>     This by all bats by survey night and by single species by survey
> night.
> >>>     Any suggestions welcomed.
> >>>
> >>>     Happy holidays all
> >>>
> >>>
> >>>     --
> >>>     Bruce W. Miller, PhD.
> >>>     Neotropical bat risk assessments
> >>>     Conservation Fellow - Wildlife Conservation Society
> >>>
> >>>     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
> >>>
> >>>     ______________________________________________
> >>>     [hidden email]  <mailto:[hidden email]>  mailing list
> -- To UNSUBSCRIBE and more, see
> >>>     https://stat.ethz.ch/mailman/listinfo/r-help
> >>>     PLEASE do read the posting guidehttp://
> www.R-project.org/posting-guide.html
> >>>     and provide commented, minimal, self-contained, reproducible code.
> >>     --
> >>     John Kane
> >>     Kingston ON Canada
> >
> >
> >     --
> >     Bruce W. Miller, PhD.
> >     Neotropical bat risk assessments
> >     Conservation Fellow - Wildlife Conservation Society
> >
> >     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
> >
> >
> >
> > --
> > John Kane
> > Kingston ON Canada
>
>
> --
> Bruce W. Miller, PhD.
> Neotropical bat risk assessments
> Conservation Fellow - Wildlife Conservation Society
>
> 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
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

Bat Dude
Hi Bert,

Tnx for taking time to reply.
For clarification... the data do EXPLICITLY indicate when each species
is active and when a feeding buzz is recorded.
That is ALL it provides based on acoustic data recorded in the field. 
Only when a species is recorded  is it identified as active.
How this is accomplished is of no importance to the question I asked.

Note this is Not "individuals" per se. but species as a group.

I appreciate you taking time to reply.
Clearly this is not a simple solution to what I assumed to be a simple
question.
Restated as...
*How best to use R to calculate occurrence of event( (A) over time vs
all events (b...n) over the same time period give the data frame work I
have.*

Cheers,
Bruce


> I will not get into your explanation of details that, like John, I
> find opaque. Please DO read Hadley's manifesto, as it appears that you
> need to organize your data more appropriately.
>
> AFAICS, however, strictly speaking your data cannot answer the
> question you have posed. **Strictly speaking** to know the proportion
> of active time bats spend feeding, **for each bat** you would need to
> know when it is active and when it is feeding during that time. You
> could then summarize this for all bats (e.g. take the average or
> median proportion) in a species or whatever. As you cannot identify
> individual bats in your data, you cannot do this -- i.e. you cannot
> answer your question.
>
> So the question then becomes: precisely **how** exactly do you propose
> using the data you have to determine when a *group* of bats are active
> and when they are feeding? How are the groups explicitly identified
> and how are their times active and feeding determined? In short, you
> need to have information that is something like:
>
> Bat.Group date   active.time.start  active.time.end 
> feeding.time.start feeding.time.end
>
> ( for a given date and bat group, there may be many multiple entries;
> perhaps for a given group, date, and active time start and end,
> several feeding time start/stop entries ( I have no idea how bats
> behave)).
>
> Until you can expicitly explain how your data can generate such
> information, I think it will be difficult/impossible to help you.
>
> Cheers,
> Bert
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

John Kane-3
 LyX Document
Hi Bruce,
<b> Combining date and times does not provide for sampling nights that roll
over after midnight. </b>
Ah yesss legacies
<b>The location, date and time does provide unique variables.</b>
Ah, i thought so
<b>Rounding to nearest minute suffices for a summary of total minutes spent
with "feeding attempts" vs total active time.</b>
Okay, that removes my worry about durations. We can just treat each entry
as one elapsed minute?
however I still do not grasp the duplicated issue. we have in my dataframe:
Species Location dtime
Ptedav 7717 2000-07-03 20:15:00
Ptedav 7717 2000-07-03 20:15:00
Ptedav 7717 2000-07-03 20:15:00
Ptedav 7717 2000-07-03 20:15:00
Ptedav 7717 2000-07-03 20:15:00
I assume that this represents 5 separate recording but that they can be
collapsed into one 1-minute data point?  If so then would not all you need
to do is run a simple table() command? To handle the Buzz one mould produce
the Buzz data.frame and merge it with the new species data.frame?
I must be missing something. It looks too simple.



On Wed, 25 Dec 2019 at 18:11, Neotropical bat risk assessments <
[hidden email]> wrote:

> Hi Bert,
>
> Tnx for taking time to reply.
> For clarification... the data do EXPLICITLY indicate when each species
> is active and when a feeding buzz is recorded.
> That is ALL it provides based on acoustic data recorded in the field.
> Only when a species is recorded  is it identified as active.
> How this is accomplished is of no importance to the question I asked.
>
> Note this is Not "individuals" per se. but species as a group.
>
> I appreciate you taking time to reply.
> Clearly this is not a simple solution to what I assumed to be a simple
> question.
> Restated as...
> *How best to use R to calculate occurrence of event( (A) over time vs
> all events (b...n) over the same time period give the data frame work I
> have.*
>
> Cheers,
> Bruce
>
>
> > I will not get into your explanation of details that, like John, I
> > find opaque. Please DO read Hadley's manifesto, as it appears that you
> > need to organize your data more appropriately.
> >
> > AFAICS, however, strictly speaking your data cannot answer the
> > question you have posed. **Strictly speaking** to know the proportion
> > of active time bats spend feeding, **for each bat** you would need to
> > know when it is active and when it is feeding during that time. You
> > could then summarize this for all bats (e.g. take the average or
> > median proportion) in a species or whatever. As you cannot identify
> > individual bats in your data, you cannot do this -- i.e. you cannot
> > answer your question.
> >
> > So the question then becomes: precisely **how** exactly do you propose
> > using the data you have to determine when a *group* of bats are active
> > and when they are feeding? How are the groups explicitly identified
> > and how are their times active and feeding determined? In short, you
> > need to have information that is something like:
> >
> > Bat.Group date   active.time.start  active.time.end
> > feeding.time.start feeding.time.end
> >
> > ( for a given date and bat group, there may be many multiple entries;
> > perhaps for a given group, date, and active time start and end,
> > several feeding time start/stop entries ( I have no idea how bats
> > behave)).
> >
> > Until you can expicitly explain how your data can generate such
> > information, I think it will be difficult/impossible to help you.
> >
> > Cheers,
> > Bert
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>


--
John Kane
Kingston ON Canada

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

PIKAL Petr
In reply to this post by Bat Dude
Well

If you can make ggplot based on your data, there should be a way to produce
summary. Just as curiosity, the data you showed us are the same as you use for
ggplot construction?

Maybe I misunderstood your question but let's assume you have records from
each location but only BUZZ time is indicated rounded to minutes.

I would use few steps
First step - sort data frame according to time and aggregate it to get minutes
of BUZZ time during a time period

Second step - merge artificial data frame with full time in minutes (either
525600 or  527040 rows if full day should be considered) with your BUZZ data
frame. This is partly complicated step if you want to consider only night time
and before merging you should remove daytime. Or maybe you are already able to
extract one data frame with Buzz activity and one data frame with timespan for
each day. Again the result of this merging step should be data frame in which
you have one time column for total time in minutes and one column indicating
when the buzz was observed.

Third step - aggregate resulting data frame to get BUZZ time in each day
either by table as suggested or by ?aggregate

Based on data from John

Here is aggregated data frame
dat2.ag<- aggregate(dat2$dtime, list(dat2$Species, dat2$Location,
format(dat2$dtime, "%d.%m.%Y %H:%M")), min)

And result of table
> table(dat2.ag$Group.1, dat2.ag$Group.2)

         7716 7717
  Buzz      2    2
  Ptedav    0    4
  Ptemes    0   13

indicating 2 minutes Buzz in location 7716 and 2 minutes in location 7717.

Cheers
Petr

> -----Original Message-----
> From: R-help <[hidden email]> On Behalf Of Neotropical bat
> risk assessments
> Sent: Thursday, December 26, 2019 12:11 AM
> To: Bert Gunter <[hidden email]>
> Cc: R. Help Mailing List <[hidden email]>
> Subject: Re: [R] What is best way to calculate % of time?
>
> Hi Bert,
>
> Tnx for taking time to reply.
> For clarification... the data do EXPLICITLY indicate when each species is
> active and when a feeding buzz is recorded.
> That is ALL it provides based on acoustic data recorded in the field. Only
> when a species is recorded  is it identified as active.
> How this is accomplished is of no importance to the question I asked.
>
> Note this is Not "individuals" per se. but species as a group.
>
> I appreciate you taking time to reply.
> Clearly this is not a simple solution to what I assumed to be a simple
> question.
> Restated as...
> *How best to use R to calculate occurrence of event( (A) over time vs all
> events (b...n) over the same time period give the data frame work I
> have.*
>
> Cheers,
> Bruce
>
>
> > I will not get into your explanation of details that, like John, I
> > find opaque. Please DO read Hadley's manifesto, as it appears that you
> > need to organize your data more appropriately.
> >
> > AFAICS, however, strictly speaking your data cannot answer the
> > question you have posed. **Strictly speaking** to know the proportion
> > of active time bats spend feeding, **for each bat** you would need to
> > know when it is active and when it is feeding during that time. You
> > could then summarize this for all bats (e.g. take the average or
> > median proportion) in a species or whatever. As you cannot identify
> > individual bats in your data, you cannot do this -- i.e. you cannot
> > answer your question.
> >
> > So the question then becomes: precisely **how** exactly do you propose
> > using the data you have to determine when a *group* of bats are active
> > and when they are feeding? How are the groups explicitly identified
> > and how are their times active and feeding determined? In short, you
> > need to have information that is something like:
> >
> > Bat.Group date   active.time.start  active.time.end feeding.time.start
> > feeding.time.end
> >
> > ( for a given date and bat group, there may be many multiple entries;
> > perhaps for a given group, date, and active time start and end,
> > several feeding time start/stop entries ( I have no idea how bats
> > behave)).
> >
> > Until you can expicitly explain how your data can generate such
> > information, I think it will be difficult/impossible to help you.
> >
> > Cheers,
> > Bert
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: What is best way to calculate % of time?

Bat Dude
Tnx all for the helpful suggestions.

Life is good.
Happy holidays
Bruce

--
Bruce W. Miller, PhD.
Neotropical bat risk assessments
Conservation Fellow - Wildlife Conservation Society

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

______________________________________________
[hidden email] 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.