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

POSIXct and plyrmr

Why do POSIXct objects not work with the plyrmr package? Here is my code: filename2 <- "/user/sgerony/mtcars" complex.function = function(x){ as.data.frame(mutate(x,date.time=as.POSIXct("2014-01-01 03:15"))) …
Samy Geronymos
  • 395
  • 2
  • 5
  • 15
0
votes
1 answer

Local Day from posixct

I've been working with some data recorded in a workplace in Hawaii, using UTC time instead of local time. Because Hawaii has a large UTC offset (UTC-10:00), this means that UTC midnight will happen in the middle of the office day, making it…
Roger Filmyer
  • 676
  • 1
  • 8
  • 24
0
votes
0 answers

formatting POSIXct doesn't remove seconds

I am trying to create a ggtitle by formatting a POSIXct time stamp: ggtitle(format(start_date, format = "%m/%d/%y %H:%M")) However, the title keeps printing seconds too, as below. How can I get rid of them?
sunny
  • 3,853
  • 5
  • 32
  • 62
0
votes
0 answers

Merge and join with Daylight Saving

I am having problems merging / joining data for the coming daylight savings shift. My time-vector d is supposed to be the controlling time-vector, so when I join with data with missing holes I just get NA values. This normally works brillantly.…
Thorst
  • 1,590
  • 1
  • 21
  • 35
0
votes
1 answer

character to date time variable in R

I have a character variable,named date with values like "2015-10-17T02:00:00" I want to convert this to date and time. I used the following, as.POSIXct(format(date, format = "%Y-%m-%d %H:%M:%S")) But I am getting, "2015-10-17 PDT" I am losing the…
haimen
  • 1,985
  • 7
  • 30
  • 53
0
votes
1 answer

How to create a DateTime variable within R

I read in a bunch of csv files into R and binded them together so I had one giant data file that looked like this This file is called data Date Time pH 1976-01-26 6:00 4.00 1976-01-26 7:30 4.05 1976-01-26 13:30 4.50 1976-01-27 …
Brian W
  • 31
  • 2
  • 10
0
votes
1 answer

Round hour in timestamp (POSIXct) to the nearest multiple of a certain value in R

I have a date/time value (POSIXct) where I want to round the "hour" value to a multiple of three (00:00, 03:00, 6:00, 9:00, 12:00...). So far I've extracted the hour as an integer, rounded it accordingly and inserted it back into a POSIXct format.…
Ratnanil
  • 1,641
  • 17
  • 43
0
votes
2 answers

Subset datatime series into 1h intervals

I have a data frame (dim: 589) with POSIXct class values. df <- read.table(header = T, stringsAsFactors = F, text = " id time par_surface 1 2014-07-19 07:10:00 907.6 2 2014-07-19 07:11:00 …
chm
  • 41
  • 5
0
votes
1 answer

R- efficiently convert time in milliseconds to as.POSIXct with varying time zones

I'd like to convert multiple time values with varying time zones, currently represented as milliseconds since 01-01-1970, to a POSIXct format. I have the following dataset: times <- c(1427450400291, 1428562800616, 1418651628795, 1418651938990,…
Omri374
  • 2,555
  • 3
  • 26
  • 40
0
votes
1 answer

Remove rows from R data.frame based on multiple conditions for POSIXct column

I have a dataframe with multiple columns where one of the columns is of class POSIXct. I would like to remove rows from my dataframe where the row's date/time (as determined from the POSIXct column) has not been preceded by a date/time within the…
0
votes
2 answers

From character to date in R

I already read a lot of questions like that, but I guess I'm facing a different character vector here, so none of the answers solved my problem. I have a character vector like the follwoing "Fri Sep 18 17:01:33 +0000 2015" I'd like to transform…
0
votes
2 answers

change specific hours of xts object with POSIXct index

I have a data frame which looks like this df = data.frame (time = c("2013-12-23 00:00:00", "2013-12-23 00:13:00", "2013-12-23 00:14:00", "2013-12-23 00:14:01", "2013-12-24 00:00:00", "2013-12-24 00:12:00", "2013-12-24…
Pat
  • 1,299
  • 4
  • 17
  • 40
0
votes
1 answer

R: Convert large column of epoch times to date object

Similar to the problem in Convert UNIX epoch to Date object in R, mine deals with one column of a large data table (about 250k rows). The column is a vector of many epoch times, e.g., dt$time= c(1388839764L, 1388846894L, 1388998785L, 1389496318L,…
Francis
  • 6,416
  • 5
  • 24
  • 32
0
votes
1 answer

Strange behavior with as.character

I have a vector or POSIXct and when I do as.character() on it, it returns numbers instead of the characters. I unfortunately cannot reproduce this with toy data but this is what is happening: d = as.POSIXct(c( "2015-09-08 17:42:07.456…
user3022875
  • 8,598
  • 26
  • 103
  • 167
0
votes
2 answers

How detailed can we report time in R?

so when I use >strptime(paste(as.character(as.POSIXct(as.numeric(substr(1438293919327731275,1,10)),origin="1970-01-01")), + substr(1438293919327731275,11,13),sep="."),"%Y-%m-%d %H:%M:%OS") [1] "2015-07-30 17:05:19" I want to know…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408