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

Converting date and time with POSIX

I have animal tracking data with position, date and time. I need to plot the data, time of day vs date/day, but I am struggling with getting the time and date in right format with the POSIX command. Here's my script up to the point where I have…
Dag
  • 569
  • 2
  • 5
  • 20
0
votes
2 answers

Time zone missing from time series

I am in the process of merging two data frames based on date-time, and seem to have run into a snag. The time column in 1 of 2 of the DF's has a timezone stamp: #Example "2012-09-28 08:15:00 MDT" And the other DF time column does not …
Chabo
  • 2,842
  • 3
  • 17
  • 32
0
votes
2 answers

R - extracting time only from xts, zoo and POSIXct

I am analyzing day to day data to see when the value would be lower. I set each day as categorical variable so I can differentiate each day. But I want to get each day plotted on top of another day instead of one continuous graph as shown…
boniface316
  • 489
  • 3
  • 17
0
votes
1 answer

How to make boxplot with a data frame with POSIXct format

I have a data frame with the POSIXct fomat. i need to make boxplot of the four columns that i have, but it is not working. Site.1350 Site.1700 Site.2000 Site.2300 15:15:08 15:29:08 15:32:50 15:34:12 15:02:32 15:23:43 15:21:06 …
Mori
  • 241
  • 1
  • 2
  • 10
0
votes
1 answer

Error in converting date and time in r

I am trying to convert "30 Jun 17 5:08 pm -0500" to POSIX time format in R. date <- c("30 Jun 17 5:08 pm -0500") mydate <- as.POSIXct(date, format="%d %b %y %I:%M %p %z") The returned result is "2017-06-30 18:08:00 EDT". Obviously, the time is…
Jian
  • 365
  • 1
  • 6
  • 19
0
votes
1 answer

Set dst with lubridate

I want to convert a character sequence of hourly french times into POSIXct. This sequence includes a dst clock change at 02:00 (CEST => CET) which causes duplicated output times. char_dates <- c("2017-10-29 01:00:00", "2017-10-29…
jlesuffleur
  • 1,113
  • 1
  • 7
  • 19
0
votes
1 answer

Calculation of date difference (BUG?) for POSIXct columns

I am using this code to get difference in hours from two POSIXct dates. x <- transform(x, HRS = ceiling(as.numeric(SHIP_DATE-PICK_DATE))) This gives accurate results. However, when I tried to find the hour differences for another similar column, I…
Arani
  • 753
  • 1
  • 9
  • 23
0
votes
2 answers

Why filter ( as.Date(opp_date) == Sys.Date() ) is bringing yesterday's data?

I love using dplyr; I use it for everything. But, the problem I'm experimenting today is the following: I'm trying to simply filter all rows fromm my opps table where opp_date is from today. So, when I use filter(opps, as.Date(opp_date) ==…
Bernardo
  • 461
  • 7
  • 20
0
votes
1 answer

Changing time zone in xts taking care of dst (daylight saving time)

Suppose we have these three dates: original_dates<- c("2015-12-31T07:00:00", "2015-12-31T08:00:00", "2015-12-31T09:00:00") and this vector: vector<- c("a", "b", "c") We transform the dates to POSIXct format: original_dates2<-…
jlp
  • 165
  • 1
  • 3
  • 12
0
votes
1 answer

Converting to Date Time Using as.POSIXct

I have a column "DateTime". Example value: 2016-12-05-16.25.54.875000 When I import this, R reads it as a Factor. Now, when I sort the dataset by decreasing "DateTime", the maximum DateTime is 23 June 2017. When I use DateTime =…
Kenneth Singh
  • 335
  • 1
  • 3
  • 15
0
votes
1 answer

Converting to POSIXct a 24h+ hour

I can convert to POSIXct most of the time like for instance: as.POSIXct( "20:16:32", format = "%H:%M:%S" ) [1] "2017-06-23 20:16:32 EDT" But once the time goes beyond 24h, it fails: as.POSIXct( "24:16:32", format = "%H:%M:%S" ) [1] NA Which makes…
Xavier Prudent
  • 1,570
  • 3
  • 25
  • 54
0
votes
0 answers

Change from character to POSIXct

This should be easy, but now I have tried for an hour, so please help. I want to change datetime <- "2017-01-18T08:04:18.570Z" > datetime [1] "2017-01-18T08:04:18.570Z" > class(datetime) [1] "character" to POSIXct. I tried: as.POSIXct(datetime,…
Jeppe Olsen
  • 968
  • 8
  • 19
0
votes
4 answers

Creating a dummy variable for certain hours of the day

i need some help. I'm currently trying to fit a linear model to hourly electricity prices. So, I was thinking of creating a dummy, which takes the value 1, if the hour of the day is between 06:00 and 20:00. Unfortunately, I have struggled so far.…
hoppe_pr
  • 11
  • 1
  • 3
0
votes
1 answer

How can I render a POSIXlt in R Markdown?

In RStudio Version 1.0.143, with the following R Markdown, I get an HTML with the POSIXlt not properly rendered. This is the markdown source: --- title: "Untitled" author: "Alessandro" date: "05 giugno 2017" output: html_document --- ```{r setup,…
Alessandro Jacopson
  • 18,047
  • 15
  • 98
  • 153
0
votes
1 answer

apply.monthly won't work with function (xts and POSIXct files)

I recently started coding using R for my master thesis and am still learning. In order to treat some meteorological data I tried creating a function. The original file is a csv file with dates and rainfalls. I extracted the dates and created a…
Axel
  • 47
  • 7