lubridate Questions

8

Solved

As a R novice I'm pulling my hair out trying to debug cryptic R errors. I have csv that containing 150k lines that I load into a data frame named 'date'. I then use lubridate to convert this charac...
Mordecai asked 12/2, 2016 at 18:40

4

Solved

This is the result I want: library(lubridate) res <- structure( c( 16160, 16251, 16343, 16435, 16525, 16616, 16708, 16800, 16891, 16982, 17074, 17166, 17256, 17347, 17439, 17531, 17621, 1...
Glutamate asked 15/8, 2022 at 12:42

1

Solved

With a recent update on Ubuntu (23.10 mantic), my R no longer recognizes "US/Eastern". sessionInfo() # R version 4.3.2 (2023-10-31) # Platform: x86_64-pc-linux-gnu (64-bit) # Running unde...
Ietta asked 18/3 at 13:50

4

Solved

Is there an easy way in R for me to itemize all valid days that occurred between two specified dates? For instance, I'd like the following inputs: itemizeDates(startDate="12-30-11", endDate="1-4-1...
Cockatrice asked 22/1, 2013 at 1:58

7

Solved

I would like to use lubridate to calculate age in years given their date of birth and today's date. Right now I have this: library(lubridate) today<-mdy(08312015) dob<-mdy(09071982) today-do...
Kanarese asked 31/8, 2015 at 13:52

4

Solved

I would like to retain my current date column in year-month format as date. It currently gets converted to chr format. I have tried as_datetime but it coerces all values to NA. The format I am loo...
Ardath asked 14/5, 2018 at 20:4

1

When looking at date-time values overlapping the timezone change from PDT to PST, it seems like R switches timezones at 1:36:14 and not at 2:00:00 as expected. Specifically, R assigns PST timezones...
Rhiannonrhianon asked 9/11, 2023 at 1:23

6

Solved

I need to find all 'next friday' corresponding to a set of dates. For instance 2015-08-03 (Monday 3rd, August, 2015) as an input should return 2015-08-07 (Friday 7th, August, 2015) as an output. ...
Booma asked 7/9, 2015 at 8:48

4

Solved

Using lubridate, how to calculate the last day of the previous quarter for a given date? The below formula doesn't seem to work for Nov 3rd, 2014 (other dates work) library(lubridate) date = as.PO...
Tinsel asked 19/11, 2014 at 11:33

2

Solved

The wday() function in the lubridate package with the option label = TRUE returns the name of the day of the week in English. I'd like to know if it is possible to get the name of day of the week i...
Cantharides asked 24/7, 2013 at 14:29

2

Solved

I am looking to combine lubridate intervals such that if they overlap, take the min value from the internal first in time and the max value from the internal last in time and summarise to create a ...
Brusquerie asked 2/11, 2020 at 20:49

6

Solved

I'm working with a csv which unfortunately has logged datetimes using the number format of 42705 although it should be 01/12/2016. I'd like to convert it to the right format in R using lubridate o...
Applegate asked 5/4, 2017 at 11:55

6

Solved

I have a large data set of time periods, defined by a 'start' and and an 'end' column. Some of the periods overlap. I would like to combine (flatten / merge / collapse) all overlapping time period...
Eriha asked 9/3, 2015 at 8:58

3

Solved

I use lubridate and figured that this would be so easy ymd("2010-01-31")+months(0:23) But look what one gets. It is all messed up! [1] "2010-01-31 UTC" "2010-03-03 UTC" "2010-03-31 UTC" "2010-...
Linguist asked 30/11, 2011 at 22:24

3

Solved

Hi I'm trying to get a sequence of dates with lubridate This doesn't work seq(ymd('2012-04-07'),ymd('2013-03-22'),by=week(1)) the base command seq(as.Date('2012-04-7'),as.Date('2013-03-22'),'w...
Protactinium asked 5/6, 2013 at 5:24

3

Solved

dates <- NULL date <- as.Date("01/01/2014","%d/%m/%Y") dates <- data.frame(date=as.Date(character()) ,cal_day_in_year_num = numeric() ,cal_week_id = numeric() ,cal_week_start_date = a...
Elburt asked 2/10, 2014 at 11:47

2

Solved

I have encountered some very peculiar behaviour in R. I think it might even be a bug, but I'm asking here to check if someone is familiar with it or knows a solution. What I'm trying to do is the ...
Alyss asked 18/4, 2018 at 13:47

3

Solved

I am looking to add and subtract six months (bond time) reliably with lubridate. For example, adding six months to 12/31/2014 should result in 6/30/2015, and adding to 2/28/2014 should result in 8/...
Susie asked 25/3, 2014 at 8:22

5

Solved

Given a POSIXct date time, how do you extract the first day of the month for aggregation? library(lubridate) full.date <- ymd_hms("2013-01-01 00:00:21")
Poisoning asked 12/5, 2014 at 6:51

7

Solved

I have the following datetime: t <- "2018-05-01 23:02:50 UTC" I want to split it to time and date. When I apply date(t) I get the date part. But when I use lubridate's hms, parse_date_time...
Varney asked 7/6, 2018 at 8:39

4

Solved

I am developing a tidyverse-based data workflow, and came across a situation where I have a data frame with lots of time intervals. Let's call the data frame my_time_intervals, and it can be reprod...
Kilter asked 8/11, 2018 at 17:46

4

Solved

I have a data frame with a character column of date-times. When I use as.Date, most of my strings are parsed correctly, except for a few instances. The example below will hopefully show you what is...
Cereal asked 30/11, 2010 at 3:40

2

Solved

I'm having trouble understanding how to use the guess_formats function in lubridate. I have a vector of dates in some unknown set/order of formats. I'd like to convert them to a Date object (or at ...
Demello asked 26/9, 2014 at 16:37

2

Solved

Looking to do the SQL equivalent of datediff in R? Basically, I want this calculation in R Delivery Date Expected Date Difference 2022-01-05 2022-01-07 -2
Ricotta asked 5/1, 2022 at 16:52

3

Solved

I have a dataset with people's complete age as strings (e.g., "10 years 8 months 23 days) in R, and I need to transform it into a numeric variable that makes sense. I'm thinking about converti...
Vane asked 1/12, 2021 at 20:59

© 2022 - 2024 — McMap. All rights reserved.