Questions tagged [posixct]

In the R language, the classes "POSIXct" and "POSIXlt" are representing calendar dates and times (to the nearest second).

The classes POSIXct and POSIXlt are representing calendar dates and times in R.

The class POSIXct represents the (signed) number of seconds since the beginning of 1970 (in the UTC timezone) as a numeric vector.

Class POSIXlt is a named list of vectors representing

  • sec: seconds (0-61)
  • min: minutes (0-59)
  • hour: hours (0-23)
  • mday: day of the month (1-31)
  • mon: months after the first of the year (0-11)
  • year: years since 1900
  • wday: day of the week, starting on Sunday (0-6)
  • yday: day of the year (0-365)
  • isdst: Daylight Savings Time flag. Positive if in force, zero if not, negative if unknown.

POSIXct is more convenient for including in data frames, and POSIXlt is closer to human-readable forms. A virtual class POSIXt exists from which both of the classes inherit.

References:

1056 questions
0
votes
1 answer

Time in the week without specific date in R

I have a list of POSIX timestamps (tweet dataset). I want to select a specific week-long period (Friday noon - Friday noon) and count how many tweets were published between current system time (e.g., Wednesday, 16pm) and the end of the period. This…
0
votes
1 answer

Categorize time series based on time points in separate dataframe in R

I have a time sequence with intervals of 10 minutes that I want to categorize according to tidal stage (low tide, high tide). Ideally ending up with e.g. : date_time tidal_stage 30/05/2016 10:50 low 30/05/2016 11:00 low 30/05/2016 11:10 …
igriev
  • 3
  • 2
0
votes
1 answer

Convert data.frame column from POSIXct to numeric produces: "Error in as.POSIXct.numeric(value) : 'origin' must be supplied"

I'm pretty new to r, and so was wondering if someone might be able to help with the error message I've been receiving. I have a data.frame AUC_sheet which contains the column AUC_sheet$sys_timewhich is in POSIXct and represents the times that blood…
cmo1
  • 3
  • 3
0
votes
1 answer

extra string is automatically inserting after converting time to POSIXct in R

In the original data frame I converted the last column to POSIXct using the following command: ordered$Start.Time <- strptime(ordered$Start.Time, format = "%I:%M %p") But after converting, an extra date string is adding to every rows Please…
0
votes
0 answers

Merging two as.POSIXct (digits.sec=2) timestamped datasets with irregular frequency - specific data issue

I am trying to merge two datasets which have irregular timestamp frequencies. I have followed an example in another post to try make this work but still it wont merge. The example I have tried to follow is adding data from an irregular time series…
Zoe
  • 1
  • 2
0
votes
0 answers

Incorrect milliseconds when converting to POSIX

When I convert my time-date column (dateWw) to POSIXct (column dateW) the first 2 rows become duplicates and the odd milliseconds in my original column become even (e.g. row 3 and 4). options(digits.secs=5) jalpy$dateW <- as.POSIXct(jalp$dateWw,…
Grace Sutton
  • 113
  • 10
0
votes
1 answer

Extracting the time information from a dataframe in R

I have a dataframe of timestmaps in R for which the dates are completely gibberish. I am looking to extract time information and substitute the correct date. But I am running into some issue. I have shown a part of the dataframe (Time_df) Time_df =…
unitedsaga
  • 111
  • 6
0
votes
1 answer

Converting Character String to Datetime

I am trying to load a dataset into r and change the type of a column into datetime. strptime, as.POSIXct or as.Date for different cases should work; This is my code: a <- structure(list(DATE = c("01/01/2011 12:00:00", "01/02/2011 12:00:00", …
M--
  • 25,431
  • 8
  • 61
  • 93
0
votes
0 answers

Format Time in R independent of a Date

How do I format time independent of a date in R? I have a time vector that I would like to add and subtract; however, when I format the vector as POSIXct(), POSIXlt(), or strptime() R attaches a date to it: > sample V1 1 1:23 2 5:20 3 2:28 4…
DataProphets
  • 156
  • 3
  • 17
0
votes
1 answer

R: conditional join based on timestamp interval

I have two data.frames: # limits ID Start_1 End_1 Start_2 End_2 1 A 2013-04-23 2013-06-09 2013-04-26 2017-02-06 2 B 2013-05-12 2013-08-08 2013-04-26 2017-02-06 3 C 2013-04-24 2013-04-26 2017-02-05 2017-02-08 and # df (header…
YGS
  • 623
  • 1
  • 6
  • 16
0
votes
1 answer

Maximum/Last element of POSIXct column in data.table?

I have a data.table with one column of POSIXcts. dt <- data.table(DateTime=seq(from=as.POSIXct("2017-02-01 00:00", tz="Europe/Berlin"), by=3600, length.out = 10), Value=1:10) I thought I can use max(), but that does not work. maxDateTime <-…
schluk5
  • 177
  • 2
  • 13
0
votes
2 answers

plotting daily rainfall data using geom_step

I have some rainfall data collected continuously from which I have calculated daily totals. Here is some toy data: Date <- c(seq(as.Date("2016-07-01"), by = "1 day", length.out = 10)) rain_mm <- c(3,6,8,12,0,0,34,23,5,1) rain_data <-…
Rory Shaw
  • 811
  • 2
  • 9
  • 26
0
votes
0 answers

as.POSIXct not working for all dates with same format

With these data: Dat <- structure(list(IndID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = "BHS_017_A", class = "factor"), DateTimeUTC = structure(1:7, .Label = c("2015.03.07 06:00:36", "2015.03.07 11:00:49", "2015.03.07 16:00:36",…
B. Davis
  • 3,391
  • 5
  • 42
  • 78
0
votes
1 answer

count bout length in sequences of different activities

I have a dataset where I need to calculate bouts lengths of a very big dataset (65400 rows!). when we were collecting the data we recorded what our focal animal was doing in each minute and second during a 5 minute time session. My sample data is as…
Taw
  • 53
  • 6
0
votes
0 answers

Can't get geom_rect to work with POSIXct dates

I'm having trouble getting ggplot to plot a rectangle covering a length of time on my plot, say from 6 AM to 12 PM. I've been studying this question: Plotting rectangles in ggplot2 - Invalid input: time_trans works with objects of class POSIXct…
Nova
  • 5,423
  • 2
  • 42
  • 62