lubridate

Why R package lubridate can't parse vector with multiple formats?

与世无争的帅哥 提交于 2019-12-10 03:57:44
问题 I'm using package lubridate to parse a vector of heterogeneously-formatted dates and convert them to string, like this: parse_date_time(c('12/17/1996 04:00:00 PM','4/18/1950 0130'), c('%m/%d/%Y %I:%M:%S %p','%m/%d/%Y %H%M')) This is the result: [1] NA NA Warning message: All formats failed to parse. No formats found. If I remove the %p in the 1st format string, it incorrectly parses the 1st date string, and still doesn't parse the 2nd, like so: [1] "1996-12-17 04:00:00 UTC" NA Warning message

How to filter or subset specific date and time intervals in R? Lubridate?

最后都变了- 提交于 2019-12-08 10:31:54
问题 I have a dataset consisting of two columns. A datetime column and a column with numerical values. Its a simple dataset, so I did not attach it.. What I need to do, is to filter or subset the data corresponding with a class schedule, so that I get a dataset/dataframe with datetime values and numerical values for the time when the class has lectures only. The class schedule is different from each day of the week, e.g. Mondays 8:00-9.50, 10.30-11.30, 14.50-15:50. Tuesdays 10.30-11.30, 14.10-15

Visualizing a staffing schedules in R

江枫思渺然 提交于 2019-12-08 07:24:27
问题 First time poster here, so please forgive any faux pas on my part. I have a set of data which consists of essentially 3 fields: 1)Position 2)Start_of_shift (datetime object) 3)End_of_Shift (datetime object) From the datetime object I can extract date, day of week, & time. The schedules are 24/7 and do not conform to any standard 3 shift etc. rotation, they are fairly specific to a site. (I am using the lubridate package) I would like to visualize Time of day vs. Day of Week to show numbers of

R - lubridate: split durations into “sub-durations”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 05:47:23
问题 I have a R tidy dataset my_durations where each case in the data frame corresponds to a sample taken over a duration of time like so: > glimpse(my_durations) Observations: 300 Variables: 5 $ sample_id <int> 2, 8, 25, 41, 59, 70, 98, 100, 105, 106, 108, 114, 119, 126,... $ site_id <int> 2, 13, 12, 23, 47, 23, 66, 72, 72, 50, 50, 54, 45, 73, 48, 7... $ start_date <dttm> 2015-04-12, 2015-06-10, 2015-07-02, 2015-07-22, 2015-07-29,... $ end_date <dttm> 2015-05-14, 2015-06-18, 2015-07-08, 2015-07

ggplot2 segment — direction when x-axis is time

帅比萌擦擦* 提交于 2019-12-07 09:42:44
问题 I have a wind speed and direction times series and I am trying to make a plot that uses line segments to depict the windspeed and direction. I need to have a basic point scatter plot of windspeed vs time (which I can create) with a line segment from each point (which is where I am getting hung up.) The length of the line has to be proportional to the windspeed and the angle needs to the wind direction. I am using ggplot2 with the geom_segment, but because x is time I cannot figure the right

convert to date and strip time?

六眼飞鱼酱① 提交于 2019-12-07 08:12:36
问题 I have some data that looks like this: dates <- structure(c(1L, 2L, 4L, 3L), .Label = c("Sat, 18 Nov 2017 00:00:00 GMT", "Thu, 16 Nov 2017 00:00:00 GMT", "Tue, 14 Nov 2017 00:00:00 GMT", "Wed, 15 Nov 2017 00:00:00 GMT"), class = "factor") I would like to convert it to a date format instead of having it as a factor. Additionally, I want to strip the 00:00:00 GMT because it is meaningless I tried lubridate but I'm having troubles with the format: library(lubridate) mdy(dates) Warning message:

Is there a way to assign DST transitions automatically in lubridate?

只愿长相守 提交于 2019-12-07 00:49:30
I have date-time pairs in a csv file that look like 11/4/2012 in one column and 12:06:08 AM in the neighboring column. They are recorded in local time (i.e., they switch to PST and PDT at the appropriate times), but there is no tz or DST indicator in the file. The only visible way to detect that is that the sequence of times does funny things. For example, on November 4, 2012, I have a sequence of times like 12:51:20 AM 1:13:08 AM 1:24:58 AM 1:40:28 AM 1:48:08 AM 1:54:08 AM 1:56:58 AM 1:04:28 AM 1:05:48 AM 1:07:18 AM 1:15:00 AM 1:39:08 AM 2:05:38 AM PST presumably begins with the 1:04:28 AM

Calculating cumulative time in R

纵饮孤独 提交于 2019-12-06 09:59:34
I have a dataframe that looks like this: POI LOCAL.DATETIME 1 1 2017-07-11 15:02:13 2 1 2017-07-11 15:20:28 3 2 2017-07-11 15:20:31 4 2 2017-07-11 15:21:13 5 3 2017-07-11 15:21:18 6 3 2017-07-11 15:21:21 7 2 2017-07-11 15:21:25 8 2 2017-07-11 15:21:59 9 1 2017-07-11 15:22:02 10 1 2017-07-11 15:22:05 I want to be able to calculate (probably with lubridate) the cumulative time spent at each POI and combine them into a table that looks something like this: POI TOTAL.TIME 1 1 00:18:18 2 2 00:01:11 3 3 00:00:03 Also, I am not sure how to deal with the time between POIs, like the 3 seconds between

Create a variable in `df1` depending on one variable of `df1` (`df1$var1`) and one variable of `df2` that is changeable depending on `df1$var1`

荒凉一梦 提交于 2019-12-06 08:36:16
I have data frame df1 that summarises fish depths over time. df1$Site tells you the site where the fish was, df1$Ind tells you the individual and df1$Depth tells you the depth where the fish was at a specific df1$Datetime . On the other hand, I have df2 that summarises the intensity of the currents over time (EVERY THREE HOURS) from the surface to 39 meters depth at intervals of 8 meters ( m0-7 , m8-15 , m16-23 , m24-31 and m32-39 ). As an example: df1<-data.frame(Datetime=c("2016-08-01 15:34:07","2016-08-01 16:25:16","2016-08-01 17:29:16","2016-08-01 18:33:16","2016-08-01 20:54:16","2016-08

ggplot2 segment — direction when x-axis is time

半世苍凉 提交于 2019-12-05 18:12:24
I have a wind speed and direction times series and I am trying to make a plot that uses line segments to depict the windspeed and direction. I need to have a basic point scatter plot of windspeed vs time (which I can create) with a line segment from each point (which is where I am getting hung up.) The length of the line has to be proportional to the windspeed and the angle needs to the wind direction. I am using ggplot2 with the geom_segment, but because x is time I cannot figure the right formula to use for xend. Here is an example of the dataframe: DateTime WINDSPEED_MPH DIR 8/29/2008 0:00