Questions tagged [lubridate]

lubridate is an R package that makes it easier to work with dates and time objects.

The lubridate package facilitates working with dates and times in . lubridate also expands the type of mathematical operations that can be performed with date-time objects. It introduces three new time span classes borrowed from :

  • durations, which measure the exact amount of time between two points
  • periods, which accurately track clock times despite leap years, leap seconds, and day light savings time
  • intervals, a protean summary of the time information between two points

Repositories

Vignettes

Other resources

Related tags

1839 questions
0
votes
1 answer

Date containing weekday/Month/Day/Year can't be correctly parsed by Lubridate

The problem I am downloaded a database from a website and the Daye column is in the following format: x <- c("Fri, Mar 1, 2019", "Sat, Mar 2, 2019", "Sun, Mar 3, 2019", "Mon, Mar 4, 2019", "Tue, Mar 5, 2019", "Wed, Mar 6, 2019", "Thu, Mar 7, 2019",…
Derek Corcoran
  • 3,358
  • 1
  • 19
  • 37
0
votes
1 answer

How to use seq() to create column of date/times with increments of milliseconds (deciseconds)

My dataframe (df) looks like this: ID CH_1 CH_2 CH_3 CH_4 date_time 1 -10096 -11940 -9340 -9972 2018-07-24 10:45:01.1 2 -10088 -11964 -9348 -9960 3 -10084 -11940 -9332 -9956 4 -10088…
LukeP
  • 93
  • 8
0
votes
2 answers

Convert Date Format from character "11JAN2016:00:00:00.000"

I am looking to convert this character vector to a date format I have tried various methods though have not been successful so far. Any assistance with this is greatly appreciated!
Davide Lorino
  • 670
  • 4
  • 19
0
votes
1 answer

Extract Month from Week and Year number

I have a dataframe where I extracted the week and year number using lubridate. I do not have the date values anymore. I want to extract the month from the week number and year number. df Week Year 1 2018 5 2018 45 2017 I…
nak5120
  • 3,410
  • 3
  • 23
  • 62
0
votes
2 answers

summarise daily value to weekly mean for each ids

i have a dataframe with ids that contain values in seperate consecutive time periods now i want to create a column which is the weekly mean of daily data. df id date value 1 2018-1-12 3 1 2018-1-13 4 1 2018-1-14 5 1 2018-1-15 5 …
Arul Dhina
  • 47
  • 6
0
votes
1 answer

Calculate maximum date interval - R

The challenge is a data.frame with with one group variable (id) and two date variables (start and stop). The date intervals are irregular and I'm trying to calculate the uninterrupted interval in days starting from the first startdate per group.…
ceefel
  • 143
  • 1
  • 10
0
votes
2 answers

How to pivot a table using a sequence of quarters between two dates

I have a data frame with two date columns (from and to). I'd like to create a year and quarter sequence between the two dates and then reshape to transform to a tall data frame. df <- structure(list(id = 1:4, from = structure(c(1L, 1L, 2L, 2L),…
alaj
  • 177
  • 10
0
votes
1 answer

calculate difference between 2 dates and print the between dates

st_day<-c(1,5,10) endday<-c(4,9,15) d<-c(1,2,3) data<-cbind(st_day,endday,d) days1<-c(1:15) dose1<-rep(c(1,2,3),each=5) result <- cbind(days1,dose1) Hello I have 2 coulmns with starts and end dates and corresponding dose with was a…
0
votes
1 answer

Search for timestamp anomalies in a dataframe R

im working with some GTFS data from Berlin and I am hitting a wall here right now. There is a stop_times.txt file for all Busstops in Berlin with 5 million rows. Two Columns (Arrival_time and Departure_time) contain anomalies, such as Arrival_time…
Skerre
  • 1
  • 1
0
votes
1 answer

Plotting add_trace from within a function: Plotly

I am trying to "functionize" my plot statements. If i want to add an additional trace from another dataframe, i am getting an error that the values on the y axis do not equal the first number of values in the first dataframe. I am not certain why…
Joe
  • 163
  • 1
  • 10
0
votes
2 answers

Categorising Time in different slots using R

Working on Time differences and want to create time slots based on different times in my dataframe. For example I do have separate column in my data frame which contains seconds. What I want to do is by checking these seconds whether it is falling…
Sharmi
  • 43
  • 9
0
votes
1 answer

Calculate average number of individuals present on each date in R

I have a dataset that contains the residence period (start.date to end.date) of marked individuals (ID) at different sites. My goal is to generate a column that tells me the average number of other individuals per day that were also present at the…
antares
  • 25
  • 5
0
votes
2 answers

Flag rows with interval overlap in r

I have a df frame containing TV viewing data, I would like to run a QC check for overlapping viewing. Let's say for the same day, same household, for each individual, each minute should be credited to one station or channel only. for example, I…
Ann
  • 178
  • 3
  • 13
0
votes
2 answers

How to add row which depends on last row using dpylr and lubridate?

Open/Close Minute Price Data. Next Minute open is always equal to previous minute close. Exemplary data set: dt open close 1998-01-02 09:30:00 100 101 1998-01-02 09:31:00 101 102 ... 1998-01-02 15:59:00 105 106 After the…
stollenm
  • 325
  • 1
  • 2
  • 9
0
votes
1 answer

Reading mdy_hms AM/PM off excel into r

I am using dplyr and lubridate. I am using read_excel to export a data.frame into R from excel. In Excel, I have a column that consists of mdy_hms AM or PM. In R, my code consists of: df$dateTimeEtc And this prints out as an example: "2017-03-07…
1 2 3
99
100