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
3 answers

apply condition if val for continuous minutes

I have this data: library(tidyverse) library(lubridate) dates <- c("01/01/18 1:00:00 PM" ,"01/01/18 1:01:00 PM", "01/01/18 1:02:00 PM" ,"01/01/18 1:03:00 PM", "01/01/18 1:04:00 PM" ,"01/01/18 1:05:00 PM", "01/01/18…
George
  • 5,620
  • 13
  • 72
  • 137
0
votes
1 answer

How to conver daily data over the period of 30 years to Monthly data for a multivariate series?

I have data frame as shown below: str(Rainfall_Complete) 'data.frame': 8221 obs. of 18 variables: $ Date : Date, format: "1985-04-29" "1985-04-30" "1985-05-01" ... $ Month : Ord.factor w/ 12 levels "Jan"<"Feb"<"Mar"<..: $…
Vasker Sharma
  • 167
  • 12
0
votes
2 answers

r: create custom "week" function

I'm writing a function that will take my df$date field (which is daily POSIXct date (by day) and create a new variable called df$wbm (wbm = week beginning Monday). I know the math works because I've done this in Excel but the syntax is not working,…
dre
  • 454
  • 3
  • 14
0
votes
1 answer

Converting a list of dates into another format in R?

I am attempting to change these lists into another type of format for use in the RJDBC package. The syntax for Oracle will only accept dates in the format of '1-OCT-18'. However, the output of this list is in the format '2018-10-01'. How can I…
Devin
  • 290
  • 2
  • 16
0
votes
2 answers

how to break a time range into monthly queries?

Consider this simple example bogus <- function(start_time, end_time){ print(paste('hey this starts on', start_time, 'until', end_time)) } start_time <- ymd('2018-01-01') end_time <- ymd('2018-05-01') > bogus(start_time, end_time) [1] "hey this…
ℕʘʘḆḽḘ
  • 15,284
  • 28
  • 88
  • 180
0
votes
1 answer

Creating a new date.time "interval" column based on start date.time and end date.time

I have a data set of start and end times of when a reef is exposed during low tide. I am trying to create a new column called "interval" using the lubridate::interval function. I have about 400 rows of…
Steven
  • 1
  • 2
0
votes
1 answer

What is the correct way to put quoted strings in rlang functions?

I am writing a fuction that I will use regularly to filter for dates and names in our database (and then to perform some monthly counting/calculations on them). I would like to know what is the correct way to insert and evaluate strings within rlang…
lim-lim
  • 17
  • 5
0
votes
1 answer

How to parse an invalid date with lubridate?

I need to parse dates and have a cases like "31/02/2018": library(lubridate) > dmy("31/02/2018", quiet = T) [1] NA This makes sense as the 31st of Feb does not exist. Is there a way to parse the string "31/02/2018" to e.g. 2018-02-28 ? So not to…
c0bra
  • 672
  • 3
  • 16
0
votes
1 answer

Plot multiple variables to compare

what the best way to plot multiple variables while comparing different parameters for the below data df1<-data.frame( Year=sample(2016:2018,100,replace = T), Month=sample(month.abb,100,replace = T), …
sai saran
  • 587
  • 7
  • 29
0
votes
1 answer

Converting character dates into Julian day

dat <- structure(list(crop_name = c("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b",…
89_Simple
  • 2,829
  • 2
  • 23
  • 67
0
votes
1 answer

Handling time data that goes over a day in R

I am trying to analyze a series large csv files that has data sampled at every 3 sec or so with R. One of the columns is timestamp recorded from the experiment, and the filename contains the date a particular experiment was performed. I am trying…
user1426485
  • 135
  • 2
  • 6
0
votes
1 answer

Dynamic column names in R

I have a problem that may be basic, but where I´m really struggling to find a solution. I´m making a report that should be updated with new dates and values every month. I need to be able to dynamically choose columns to do calculations on, but…
0
votes
2 answers

Using a S3 method from an unloaded R package

Let's look at the example of the method months for type numeric from the lubridate package. When loading the package, everything works as expected: library(lubridate) #> #> Attaching package: 'lubridate' #> The following object is masked from…
Lorenz Walthert
  • 3,219
  • 1
  • 13
  • 20
0
votes
3 answers

Subset dates with a given weekday and select next date if weekday is missing

I'm able to find a lot of info on SO regarding handling subsetting dates to a certain weekday (e.g. Get Dates of a Certain Weekday from a Year in R). However, I am unable to find any that implement a fallback logic that I'd like. Specifically, if…
jmuhlenkamp
  • 1,993
  • 1
  • 12
  • 33
0
votes
0 answers

R: calculate closing time for chamber N2O flux measurements

I performed static N2O chamber measurements that I would like to analyse now using the "gasfluxes package" https://cran.r-project.org/web/packages/gasfluxes/gasfluxes.pdf. I measured different samples (POTS) during 10 min intervals. Each sample was…
Ch_soil
  • 13
  • 2
1 2 3
99
100