Questions tagged [posixlt]

Class `POSIXlt` more conveniently represents the result of Class `POSIXct` (the number of seconds since the beginning of 1970) as a numeric vector of more directly accessable values for seconds, minutes, hours, days, months, years etc.

Class POSIXct represents the (signed) number of seconds since the beginning of 1970 (in the UTC time zone) as a numeric vector. Class "POSIXlt" is a named list of vectors representing

sec - 0–61: seconds.

min - 0–59: minutes.

hour - 0–23: hours.

mday - 1–31: day of the month

mon - 0–11: months after the first of the year.

year - years since 1900.

wday - 0–6 day of the week, starting on Sunday.

yday - 0–365: day of the year.

isdst - Daylight Saving Time flag. Positive if in force, zero if not, negative if unknown.

zone - (Optional.) The abbreviation for the time zone in force at that time: "" if unknown (but "" might also be used for UTC).

gmtoff - (Optional.) The offset in seconds from GMT: positive values are East of the meridian. Usually NA if unknown, but 0 could mean unknown.

151 questions
3
votes
1 answer

Parse string with a 5-digit year to POSIXct

I want to parse a character with a 5-digit (or more) year, e.g. 10000-01-01 01:00:00 to class POSIXct. A 4-digit year is of course no problem. For example, as.POSIXct("1000-01-01 01:00:00") But with a 5-digit year, e.g. 10000, as.POSIXct…
WCMC
  • 1,602
  • 3
  • 20
  • 32
3
votes
3 answers

finding all flights that have at least three years of data in R

I am using the flight dataset that is freely available in R. flights <- read_csv("http://ucl.ac.uk/~uctqiax/data/flights.csv") Now, lets say i want to find all flight that have been flying for at least three consecutive years: so there are dates…
Nneka
  • 1,764
  • 2
  • 15
  • 39
3
votes
1 answer

drop_na( ) cannot work on POSIX-lt object

According to the title, I make a simple example to test drop_na {tidyr} : library(tidyr) library(dplyr) # (1.) produce a dataset with two POSIX type "ct" and "lt" data <- data.frame(n = 1:5) data$ct <- as.POSIXct(Sys.time() + rnorm(5) *…
Darren Tsai
  • 32,117
  • 5
  • 21
  • 51
3
votes
1 answer

strptime returns two NAs while it works fine before and after

what am I doing wrong?? I use dates<- strptime(dataframe$Measurement.Time,"%d.%m.%Y %H:%M",tz="") to convert the character strings into dates. This works perfectly on 14780 observations. But in two cases it returns NA. This is an example…
Habesha
  • 31
  • 3
3
votes
1 answer

How to parse date and time with milliseconds, spread across multiple columns?

I am having issues with incorporating milliseconds in formatting date and time which has milliseconds. Description: date format in csv is spread across first 3 columns 2014/12/22,14:48:51,800 as date, time and milliseconds , respectively. So, I…
3
votes
1 answer

Reading a string column in xlsx with date and time values

I am reading a .xlsx file using R. One of the columns is called "Date" and it has the following format: "20/10/2014 12:00:00 am". However, when I read the file using R's xlsx package, the value becomes 41932-- class factor. How can I read the…
EFL
  • 938
  • 4
  • 11
  • 23
3
votes
1 answer

dplyr - mutate_each - colswise coercion to POSIXlt fails

I recently came across dplyr and - as a newbie - like it very much. Hence, I try to convert some of my base-R code into dplyr-code. Working with air traffic control data, I am struggling with coercing timestamps using lubridate and as.POSIXlt to…
Ray
  • 2,008
  • 14
  • 21
3
votes
1 answer

in R, apply function to multiple inputs to return array of POSIXlt

I have a function to create a timestamp from multiple string inputs: # Create timestamp from date, time, and timezone strings str_to_dt <- function(date_str, time_str, tz_str){ as.POSIXlt(x = paste(date_str, time_str), format = "%m/%d/%Y %H:%M", …
C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
2
votes
2 answers

Vectors of POSIXlt objects

I have a data frame with columns of years, months, days, and hours. I want to add a column in which each row represents the POSIXlt object defined by the years, months, days, and hours on that row. The conversion for each row is straightforward,…
JeremyC
  • 445
  • 2
  • 14
2
votes
1 answer

Why does R add non-existing microseconds/nanoseconds to date-time objects?

I have datetimes written in format "%d-%b-%Y %H:%M:%S.%OS", so for example "25-Apr-2021 18:31:56.234", that is to the precision of milliseconds. And when parse that to time object I see values are not the same, sometimes it adds 1 microsecond or…
Vladimir
  • 1,243
  • 5
  • 19
  • 23
2
votes
1 answer

Points not aligned on x-axis of ggplot 1-column facet wrap

Please kindly check and advice on how I can resolve the difference in the two plots generated by the following script: time1 <- c( as.POSIXlt("2021-05-02 23:57:29"), as.POSIXlt("2021-05-02 23:58:29"), as.POSIXlt("2021-05-02 23:59:29"), …
juandering
  • 23
  • 3
2
votes
2 answers

How to change time in combined time-date variable (POSIXlt)?

I'm working with a combined time-date variable (format: 2019-05-25 09:02:52; see code below) for times on which ESM measurements were taken. These measurements fell into fixed intervals and I now want to set all times in the interval to the average…
ELdeM
  • 43
  • 4
2
votes
1 answer

how to set the day, month and year in a posixlt in r?

i have to fix a date in a data frame. the date comes in as "16/12/2006", and the time comes in as "17:24:00". i want to construct a posixlt with the combined date and time. i tried: fixTime2<-function(date,time) { # replaces the date in time with…
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
2
votes
1 answer

Convert numeric time format to POSIXlt

I have time imported from a file. The column is considered numeric and is as follows: head(RawData$TimeStart, 10) [1] 0.00 0.00 0.00 30.19 0.00 25.00 0.00 9.20 0.00 0.00 This data represents a sample taken at 0.0 minutes and at 30 minutes,…
user2716568
  • 1,866
  • 3
  • 23
  • 38
2
votes
1 answer

Concatenating Dates into a single Column

My dates in Submitted.on column are of different formats hence resorted to converting the various formats separately and then concatenating them into a new column using ifelse and as.Date. But the however when I use strptime to have the timestamp…
Jil Jung Juk
  • 690
  • 2
  • 9
  • 21
1
2
3
10 11