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
-1
votes
2 answers

How to manipulate the time part of a date column?

How do I write this code (hour is from lubridate package)? Objective: if hour part of PICK_DATE is later than 16:00, the ADJ_PICK_DATE should be next day 03:00. If the hour part of PICK_DATE is earlier than 03:00, then ADJ_PICK_DATE is to be same…
Arani
  • 753
  • 1
  • 9
  • 23
-1
votes
1 answer

Aggregating second-by-second sampling interval to 30 sec interval, POSIXct

New to [R]studio and respectfully requesting help. Goal: I'd like to take data collected at 1 second intervals, collapse it to 30 sec intervals, and, subsequently, have the "mean" of each variable associated with it. Here is what my data looks…
ETW
  • 1
-1
votes
1 answer

unable to convert to date time in R

structure(list(Datetime = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "2016-10-19 00:00:00", class = "factor")), .Names = "Datetime", row.names = c(NA, -6L), class = "data.frame") when I try to convert Datetime to POSIXct as…
user1471980
  • 10,127
  • 48
  • 136
  • 235
-1
votes
1 answer

Merge 2 date datasets

Reproductible code library("zoo") library("xts") x <- structure(c("2012-09-27 09:08:37", "2012-09-29 10:06:33", "2012-10-01 09:44:36","2012-10-04 14:37:05", "2012-10-15 13:18:21", "2012-10-17 17:33:46","2012-10-18 11:52:13", "2016-10-06 15:11:01",…
Badita Florin
  • 113
  • 1
  • 7
-1
votes
1 answer

Apply which.min on POSIXct

I am trying to find the row-wise minimum from a data frame of POSIXct. But using apply with which.min does not work: df <- data.frame(date1 = as.POSIXct(c("2016-01-01", "2016-02-01")), date2 = as.POSIXct(c("2015-10-01",…
jlesuffleur
  • 1,113
  • 1
  • 7
  • 19
-1
votes
1 answer

How do I convert the below string as date-time in R?

I have the following character vector that contains date/time. I want to convert them to a date format and I tried the below methods : as.Date() and as.POSIXct() time <- c("Oct 01,2015 15:38:31 ", "Oct 05,2015 11:07:14", "Oct 11,2015 14:15:51 ",…
sunitprasad1
  • 768
  • 2
  • 12
  • 28
-1
votes
2 answers

R date conversion

I have a date in format "%e-%a-%y" example: "13-Mar-15" I need to convert this date in format "%Y-%m-%d" I have tried format(example, "%Y-%m-%d") without success. Also tried format(as.POSIXct(example, format="%e-%a-%y"), format="%Y-%m-%d") without…
TTR
  • 173
  • 1
  • 13
-1
votes
2 answers

Convert Data Frame in R to Time Series - DATE HOUR FORMATTING

I have data three quarters from July-September by Date Hour i.e. 07/01/2013 0:00 , 07/01/2013 1:00. I should have maximum possible 92 * 24 = 2208 Observations. For some reason I have above 2208 observations in some of my data frames. Here is the…
vagabond
  • 3,526
  • 5
  • 43
  • 76
-2
votes
2 answers

How to convert date & time to numeric by using POSIXct and how to calculate the time?

Hi Friends Both these columns(starttime/stoptime) are in Character class ,how could I convert to numeric(POSIXct) to find the time consumption ,Thank you starttime 12/31/2015 23:48 12/31/2015 23:47 12/31/2015 23:37 12/31/2015…
-2
votes
1 answer

Trouble with R function POSIXct recognising the time format of my file

I'd like to know why this R statement is unable to interpret the time format provided in my dataset column Occurred Date / Time? I'm attempting to index the .dataframe and order by Occurred Date / Time column. > head (test[,c(0:4)]) # A tibble: 6 x…
-2
votes
1 answer

How to add a text annotations to a time series ggplot

I know about annotate() and that you need to add the x and y coordinates. The problem is my x is class ""POSIXct" "POSIXt." So when I try to use annotate, R responds, object needs to be POSIXct. I have tried various combinations trying to fix this…
user8369515
  • 485
  • 1
  • 5
  • 16
-2
votes
1 answer

Converting to time format - Shows error - Unknown timezone

I have dataset in this format 1/2/2015 9:43 I am not sure why the code below showing me warnings. in_time <- sapply(in_time, function(x) as.POSIXlt(x, origin="1-2-2015","%d-%m-%Y %H:%M")) There were 50 or more warnings (use warnings() to see the…
-2
votes
2 answers

POSIXct objects showing as numeric

k <- file.Folder$LPRS.time[1] + lag*60 > k [1] "2017-03-31 00:15:00 IST" > file.Folder$start.time[1] <- file.Folder$LPRS.time[1] + lag*60 > file.Folder$start.time[1] [1] 1490899500 file.Folder$start.time is a new column created just at the last…
figs_and_nuts
  • 4,870
  • 2
  • 31
  • 56
-2
votes
1 answer

Plotting times in POSIXct over course of a day

I am dealing with a dataset of crimes and want to determine the peak time for a crime. I have successfully created a vector of POSIXct types (e.g., "2017-01-01 00:00:00 EST") but can only map all the dates using hist.POSIXt. To clarify, I would like…
Cilantro Ditrek
  • 1,047
  • 1
  • 14
  • 26
-2
votes
1 answer

Does timezone conversion in R give correct values?

For sanity check, I want to see if a few minutes after the transition time from DST to ST, would give the same hour for the equivalent Eastern time and UTC. In Canada, on the first Sunday of November time changes from 2:00 AM to 1:00 AM. For…
asiehh
  • 553
  • 12
  • 22
1 2 3
70
71