Skip to content

Instantly share code, notes, and snippets.

@hilaryparker
Created June 2, 2014 01:19
Show Gist options
  • Save hilaryparker/2a83ca521353e8478c92 to your computer and use it in GitHub Desktop.
Save hilaryparker/2a83ca521353e8478c92 to your computer and use it in GitHub Desktop.
sunrise.set.R function
sunrise.set <- function (lat, long, date, timezone = "UTC", num.days = 1)
{
lat.long <- matrix(c(long, lat), nrow = 1)
day <- as.POSIXct(date, tz = timezone)
sequence <- seq(from = day, length.out = num.days, by = "days")
sunrise <- sunriset(lat.long, sequence, direction = "sunrise",
POSIXct = TRUE)
sunset <- sunriset(lat.long, sequence, direction = "sunset",
POSIXct = TRUE)
ss <- data.frame(sunrise, sunset)
ss <- ss[, -c(1, 3)]
colnames(ss) <- c("sunrise", "sunset")
return(ss)
}
@Jaip2018
Copy link

I have data in hourly data, how to separate my hourly data in "Day" and "Night".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment