chron

Finding the Mean and SD of time variables, taking times past midnight into account in R

南笙酒味 提交于 2021-01-29 14:16:21
问题 I am trying to figure out how to take the mean and SD of bedtimes, but I am having difficulty managing times after midnight. These concepts make sense logically (I think) but figuring out how to code it in R is tricky. Right now, those pull the mean down toward daytime (i.e., toward noon), when they logically should pull the mean toward nighttime (i.e., toward midnight). Here is an example, where the mean time should be closer to midnight but isn't. library(chron) In.Bed.Date <- c("6/15/2019"

Test if a date is a holiday in r

那年仲夏 提交于 2020-01-03 06:42:10
问题 I have a data set that looks like this: 9/1/2014 00:00:25 9/1/2014 00:00:28 9/1/2014 00:00:40 There are many more observations... I want to create a column that indicates if a date is a holiday or not , so i used the is.holiday() function. This is my code: final_uber_4$is_holiday <- is.holiday(final_uber_4$interv) The problem is that it returnes 0 for all the observations although I know for sure there are holidays in my data set. 回答1: I assume you are using the is.holiday function from the

Test if a date is a holiday in r

我的梦境 提交于 2020-01-03 06:41:05
问题 I have a data set that looks like this: 9/1/2014 00:00:25 9/1/2014 00:00:28 9/1/2014 00:00:40 There are many more observations... I want to create a column that indicates if a date is a holiday or not , so i used the is.holiday() function. This is my code: final_uber_4$is_holiday <- is.holiday(final_uber_4$interv) The problem is that it returnes 0 for all the observations although I know for sure there are holidays in my data set. 回答1: I assume you are using the is.holiday function from the

R chron times() function won't work

断了今生、忘了曾经 提交于 2019-12-12 16:26:25
问题 I'm trying to convert a time to seconds since midnight. I'm having a hard time getting the times() function from the chron package to work. Here's how I'm using it: > library(chron) > 24 * 24 * 60 * (times(50)) Error in 24 * 24 * 60 * (times(50)) : non-numeric argument to binary operator > > > library(chron) > 24 * 24 * 60 times(5000) Error: unexpected symbol in "24 * 24 * 60 times" Any suggestions? UPDATE: > sessionInfo() R version 2.14.0 (2011-10-31) Platform: i386-pc-mingw32/i386 (32-bit)

How to filter HadISST raster data in a range of months in R?

ε祈祈猫儿з 提交于 2019-12-12 06:36:34
问题 I'm trying to study the Sea Surface Temperature (SST) correlation with tropical-cyclone activity in a certain range of months. The data I'm using is from the Hadley Centre (in NetCDF format) using the get_anual_ssts() function from the hadsstR package. get_annual_ssts <- function(hadsst_raster, years = 1969:2011) { mean_rasts <- apply(matrix(years), 1, function(x) { yearIDx <- which(chron::years(hadsst_raster@z$Date) == x) subset_x <- raster::subset(hadsst_raster, yearIDx) means <- raster:

plot chron times as hours from origin

心不动则不痛 提交于 2019-12-10 23:27:59
问题 I have a set of chron times that is the difference between two time points. These values range from slightly negative to slightly greater than 1. Chron displays these values as a fraction of days because some of the values are greater than 1. When I plot these values in ggplot, I tried using scale_y_chron() to correctly annotate the y axis, however scale_y_chron() appears to only plot time within a 24 hour period. Is there any way that I can annotate the axis as HH:MM from 00:00? # data: time

In using timeDate R package, I receive an error when specifying GBNewYearsEve

给你一囗甜甜゛ 提交于 2019-12-08 02:06:04
问题 IN looking for a way to modify the .Holiday object in the chron package I discovered this solution How to define holidays for is.holiday() chron package in R Which works very well in itself, except when I include "GBNewYearsEve" in hlist, I recieve an error: Error in get(as.character(FUN), mode = "function", envir = envir) : object 'GBNewYearsEve' of mode 'function' was not found This error doesn't appear if GBNewYearsEve is removed from the list. What have I missed? Example Working Code:

In using timeDate R package, I receive an error when specifying GBNewYearsEve

流过昼夜 提交于 2019-12-06 06:15:50
IN looking for a way to modify the .Holiday object in the chron package I discovered this solution How to define holidays for is.holiday() chron package in R Which works very well in itself, except when I include "GBNewYearsEve" in hlist, I recieve an error: Error in get(as.character(FUN), mode = "function", envir = envir) : object 'GBNewYearsEve' of mode 'function' was not found This error doesn't appear if GBNewYearsEve is removed from the list. What have I missed? Example Working Code: library(chron) library(timeDate) hlist <- c("GBMayDay", "GBBankHoliday", "GBSummerBankHoliday",