Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Adding a new column in R data frame based on time intervals. Day/Night

$
0
0

I want to add a new column to my dataframe based on a time interval. For the time 10:00 - 15:00 I want to add "day" in the new column, for 22:00-03:00 I want to add "night". Additionally I want to exclude all rows which aren't in one of the intervals

I've used as.POSIXct already.

This is what I want:

hour    D_N
10:31   day
01:10   night
12:03   day
14:51   day


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>