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

Create column based on dates in another dataframe

$
0
0

I would like to determine the tidal state in one dataframe (DF)

DF <- data.frame(Date = c(2012-01-01 05:37:00,2012-01-01 05:50:00,2012-01-01 05:58:00), Tide= NA)

based on the following dataframe:

Tides <- data.frame(Date=c(2012-01-01 05:31:00,2012-01-01 11:30:00,2012-01-01 17:58:00), Tide=c(low tide,high tide,low tide))

So I want to divide the data into low and high tide, based on if it's closer to low or high tide, based on this second dataframe.

I was trying to create intervals with more datapoints first in the Tides dataframe but I didn't succeed and I'm also not sure if that is the correct way to start

I would like to have this result, but the data is over several years so it can't be done manually.

DF <- data.frame(Date = c(2012-01-01 05:37:00,2012-01-01 05:50:00,2012-01-01 05:58:00), Tide= c(low tide,low tide,low tide))


Viewing all articles
Browse latest Browse all 201839

Trending Articles



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