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

What do "ct" and "lt" (in POSIXct and POSIXlt) mean?

I am interested, what "ct" and "lt" (in POSIXct and POSIXlt) mean. Are they some kind of abbreviations? E.g., does "ct" mean "calendar time" and "lt" something else?
GegznaV
  • 4,938
  • 4
  • 23
  • 43
12
votes
1 answer

How to expand Posixct field in R str()?

I am trying to expand the amount of factors shown in one custom Posixct field where the normal way (str(DF, list.len=ncol(DF), vec.len=20)) does not work. I request here 20 but it shows all the time two ("2017-01-01 08:40:00" "2017-01-01 08:50:00"…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
12
votes
1 answer

Plotting POSIXct timestamp series with ggplot2

I would like to plot the results of a load test. Each row contains a timestamp in seconds and the response time for the request. For example: timestamp <- c(1441229131, 1441229132, 1441229133, 1441229134, 1441229135) response.time <- c(22, 48, 48,…
oneself
  • 38,641
  • 34
  • 96
  • 120
11
votes
2 answers

POSIXct object is NA, but is.na() returns FALSE

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 following: I have a data frame with dates assigned to…
A. Stam
  • 2,148
  • 14
  • 29
11
votes
2 answers

R time_trans works with objects of class POSIXct

I have data with stock prices(data). Stock data I would like to visualize it. I first use ggplot R plotting to visualize the series. Date Closed 2010-07-19 0.0808 2010-07-20 0.7547 When I used below code my_date_format <-…
little girl
  • 285
  • 1
  • 3
  • 15
11
votes
2 answers

ifelse() stripping POSIXct attribute from vector of timestamps?

This is weird: R's ifelse() seems to do some (unwanted) casting: Lets say I have a vector of timestamps (possibly NA) and NA values should be treated differently than existing dates, for example, just ignored: formatString = "%Y-%m-%d…
Fabian Werner
  • 957
  • 11
  • 19
11
votes
3 answers

05:00:00 - 28:59:59 time format

I have dataset where time.start vary from 5:00:00 to 28:59:59 (i.e. 01.01.2013 28:00:00 is actually 02.01.2013 04:00:00). Dates are in %d.%m.%Y format. Date Time.start 01.01.2013 22:13:07 01.01.2013 22:52:23 01.01.2013 …
BiXiC
  • 933
  • 3
  • 9
  • 29
10
votes
4 answers

Converting time format to numeric with R

In most cases, we convert numeric time to POSIXct format using R. However, if we want to compare two time points, then we would prefer the numeric time format. For example, I have a date format like "2001-03-13 10:31:00", begin <- "2001-03-13…
Frank Wang
  • 1,462
  • 3
  • 17
  • 39
10
votes
5 answers

How to avoid that anytime() "updates by reference"?

I want to convert a numeric variable to POSIXct using anytime. My issue is that anytime() converts the input variable as well - I want to keep it. Simple example: library(anytime) t_num <- 1529734500 anytime(t_num) # [1] "2018-06-23…
Henrik
  • 65,555
  • 14
  • 143
  • 159
10
votes
6 answers

Determine season from Date using lubridate in R

I have a very big dataset with a DateTime Column containing POSIXct-Values. I need to determine the season (Winter - Summer) based on the DateTime column. I've created a function which works fine on a small dataset, but crashes when I use it on the…
Ratnanil
  • 1,641
  • 17
  • 43
10
votes
2 answers

Unexpected output from all.equal.POSIXct

I'm getting unexpected output from the all.equal method in R, specifically the implementation for POSIXct, all.equal.POSIXct. t <- Sys.time() isTRUE(all.equal(t, t+1)) returns TRUE, and isTRUE(all.equal(t, t+1, scale = 1)) returns FALSE. However,…
Ash
  • 237
  • 2
  • 11
9
votes
1 answer

ggplotly() does not display geom_vline / geom_hline when data is POSIXct

I am trying to make a graph with "time markers". These time markers are vertical lines for certain dates. Time data are POSIXct format. I would like to use the awesome interactive interface of Plotly and use my ggplot objects in it. The problem is…
Paul
  • 2,850
  • 1
  • 12
  • 37
9
votes
1 answer

Using ROracle dbWriteTable to write POSIXct back to Oracle DB

In Oracle DB: DESCRIBE ORACLE_DB_TABLE; |---------------------------------------| | Column Name | Data Type | |---------------------------------------| | TRANSACTION_TIME | DATE | | TRANSACTION_ID | VARCHAR2 (20 Byte)…
chengcj
  • 888
  • 2
  • 8
  • 22
9
votes
2 answers

How to create date from datetime (using lubridate)?

Assume I have created a variable containing date and time: a <- ymd_hms("2014-01-01 12:23:34") How do I create another variable that only has the date? That is, what should I do to transform a's value to be identical to b's value where b is b <-…
paljenczy
  • 4,779
  • 8
  • 33
  • 46
9
votes
2 answers

Get correct datetime from Oracle query via ROracle in R

I am using ROracle within R to access an Oracle database. I noticed that probably since the summer-time change, any DATE (datetime) Oracle column are now converted wrongly (I get an hour LESS in R than in the Oracle DB). From page 12 of the…
statquant
  • 13,672
  • 21
  • 91
  • 162
1 2
3
70 71