Re: [R] need to delete by time, not date

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 10 May 2011 11:18:31 -0400

On May 10, 2011, at 11:06 AM, Schatzi wrote:

> I have a matrix where one column has a date and another column has a
> time. I
> need to delete all times before 6am. I had combined the Date and
> Time column
> into DateTime.
>
> Mat1:
> Weight Date Time
> 7.6 04/28/11 09:03
> 8.4 04/29/11 03:11
> 8.6 04/29/11 05:32
> 8.6 04/29/11 09:53
> 1.4 05/01/11 19:52
>
> I tried just picking up the time:
>
> as.POSIXct(Mat1$Time, format = "%H:%M")
>
> but this assigns the time value today's date.

Since these are either character strings (or factors) at the moment ... and if they are matrices they are character...

Mat1[Mat1$Time >= "06:00" , ]

If actually a dataframe then

Mat1[as.character(Mat1$Time) >= "06:00" , ]

In the future please include the output of dput(Mat1).

>
> The final matrix should look like:
> Weight Date Time
> 7.6 04/28/11 09:03
> 8.6 04/29/11 09:53
> 1.4 05/01/11 19:52
>
>

David Winsemius, MD
West Hartford, CT



R-help_at_r-project.org mailing list
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. Received on Tue 10 May 2011 - 15:20:47 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 15:40:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive