Ahh, that makes more sense now. Thanks again. On Mon, Jan 2, 2017 at 1:44 PM, Roy Mendelssohn - NOAA Federal < roy.mendelss...@noaa.gov> wrote:
> The trick is to realize times are stored internally in a special format, > though they can be displayed in several ways based on the internal > representation. The trick in doing comparison with times is to make > certain what you are comparing with has also been put into the same > internal time format. This should make clear the basis for the logical > tests: > > > as.numeric(test) > [1] 34200 36000 37800 39600 > > > > as.numeric(hm("10:00")) > [1] 36000 > > > > -Roy > > > > On Jan 2, 2017, at 12:39 PM, Joe Ceradini <joecerad...@gmail.com> wrote: > > > > Bingo! Thanks! I somehow couldn't find an example like that via google. > > > > Joe > > > > On Mon, Jan 2, 2017 at 1:35 PM, Roy Mendelssohn - NOAA Federal > > <roy.mendelss...@noaa.gov> wrote: > >>> test > hm("10:00") > >> [1] FALSE FALSE TRUE TRUE > >>> test[test > hm("10:00")] > >> [1] "10H 30M 0S" "11H 0M 0S" > >> > >> -Roy > >> > >> > >>> On Jan 2, 2017, at 12:27 PM, Joe Ceradini <joecerad...@gmail.com> > wrote: > >>> > >>> Thanks for the reply Roy! > >>> > >>> Perhaps you're showing me the way and I'm missing it - how would I > >>> subset to only 1030 and 1100, excluding 1000? It seems I would need to > >>> say, give me all time greater than 10:00, but the hours and minutes > >>> are in separate slots, which is throwing me off. > >>> > >>> Thanks again. > >>> > >>> On Mon, Jan 2, 2017 at 1:13 PM, Roy Mendelssohn - NOAA Federal > >>> <roy.mendelss...@noaa.gov> wrote: > >>>> Hi Joe: > >>>> > >>>> See below. > >>>>> On Jan 2, 2017, at 12:01 PM, Joe Ceradini <joecerad...@gmail.com> > wrote: > >>>>> > >>>>> Hi folks, > >>>>> > >>>>> I must be missing something obvious/painfully simple here.... > >>>>> > >>>>> How do I subset a time vector based on hours AND minutes? So, in this > >>>>> example, I want all time greater than 10:00, i.e., 10:30 and 11:00. > >>>>> I'm working with lubridate which separates the hours and minutes into > >>>>> separate slots. > >>>>> > >>>>> require(lubridate) > >>>>> > >>>>> test <- hm(c("9:30", "10:00", "10:30", "11:00")) > >>>>> test > >>>>> [1] "9H 30M 0S" "10H 0M 0S" "10H 30M 0S" "11H 0M 0S" > >>>>> > >>>>> This gets 11 but not 1030 > >>>>> test[test@hour > 10] > >>>>> [1] "11H 0M 0S" > >>>>> > >>>>> This gets 1030 but not 11 > >>>>> test[test@hour > 9 & test@minute > 0] > >>>>> [1] "10H 30M 0S" > >>>> > >>>> test[test@hour > 9] > >>>> [1] "10H 0M 0S" "10H 30M 0S" "11H 0M 0S" > >>>> > >>>> > >>>> You are using a logical "and" in your test - so the condition > "test@minute > 0" isn't met for 11:00 and therefore it doesn't show up. > as both conditions must be met You could also do: > >>>> > >>>>> test[test@hour >= 10] > >>>> [1] "10H 0M 0S" "10H 30M 0S" "11H 0M 0S" > >>>> > >>>> -HTH, > >>>> > >>>> Roy > >>>> > >>>>> > >>>>> Thanks and happy new year! > >>>>> Joe > >>>>> > >>>>> ______________________________________________ > >>>>> R-help@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. > >>>> > >>>> ********************** > >>>> "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > >>>> ********************** > >>>> Roy Mendelssohn > >>>> Supervisory Operations Research Analyst > >>>> NOAA/NMFS > >>>> Environmental Research Division > >>>> Southwest Fisheries Science Center > >>>> ***Note new street address*** > >>>> 110 McAllister Way > >>>> Santa Cruz, CA 95060 > >>>> Phone: (831)-420-3666 > >>>> Fax: (831) 420-3980 > >>>> e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > >>>> > >>>> "Old age and treachery will overcome youth and skill." > >>>> "From those who have been given much, much will be expected" > >>>> "the arc of the moral universe is long, but it bends toward justice" > -MLK Jr. > >>>> > >>> > >>> > >>> > >>> -- > >>> Cooperative Fish and Wildlife Research Unit > >>> Zoology and Physiology Dept. > >>> University of Wyoming > >>> joecerad...@gmail.com / 914.707.8506 > >>> wyocoopunit.org > >> > >> ********************** > >> "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > >> ********************** > >> Roy Mendelssohn > >> Supervisory Operations Research Analyst > >> NOAA/NMFS > >> Environmental Research Division > >> Southwest Fisheries Science Center > >> ***Note new street address*** > >> 110 McAllister Way > >> Santa Cruz, CA 95060 > >> Phone: (831)-420-3666 > >> Fax: (831) 420-3980 > >> e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > >> > >> "Old age and treachery will overcome youth and skill." > >> "From those who have been given much, much will be expected" > >> "the arc of the moral universe is long, but it bends toward justice" > -MLK Jr. > >> > > > > > > > > -- > > Cooperative Fish and Wildlife Research Unit > > Zoology and Physiology Dept. > > University of Wyoming > > joecerad...@gmail.com / 914.707.8506 > > wyocoopunit.org > > ********************** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ********************** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new street address*** > 110 McAllister Way > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK > Jr. > > -- Cooperative Fish and Wildlife Research Unit Zoology and Physiology Dept. University of Wyoming joecerad...@gmail.com / 914.707.8506 wyocoopunit.org [[alternative HTML version deleted]] ______________________________________________ R-help@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.