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

Replace characters with dates in dataframe in r

I have a dataframe with dates stored as strings. The conversion with strptime works fine when I test it in the terminal, but when I want to assign the date in the original cell, I get an error: provided 11 variables to replace 1 variables This must…
Arkantos
  • 23
  • 3
1
vote
1 answer

How to change a dataframe including Date-time with daily resolution to half-hourly resolution

I have a data.frame like WWH V1 V2 V3 Names 2018-01-01 0.3240454 0.4044979 0.6208009 a 2018-01-01 0.7240454 0.6044979 0.9208009 b 2018-01-01 0.6124702 0.9391351 0.1459288 c 2018-01-02 0.5754003…
Nile
  • 303
  • 2
  • 11
1
vote
0 answers

R POSIXct wrongly parse seconds with milliseconds

I have a problem in R with changing seconds with decimal places into a date. Example: seconds <- c(1124925778.888, 1124925778.889) > as.POSIXct(seconds, origin = "1970-01-01 00:00:00.000") [1] "2005-08-25 01:22:58.888 CEST" "2005-08-25 01:22:58.888…
Jo.Hen
  • 55
  • 6
1
vote
1 answer

In R, do as.POSIXlt and strptime require different formats?

Consider the following R console output. > Sys.getlocale() [1]…
Rodrigo
  • 4,706
  • 6
  • 51
  • 94
1
vote
3 answers

How to convert whole column of dates/times from one time zone to another in R?

Every row has a different origintimezone. I need to make use of the standardformat_new column which is in the origintimezone time to create a new column where the time follows the com_timezonenames. A simplified version would be something like this…
teo93
  • 129
  • 3
  • 12
1
vote
2 answers

Why are some datetime values being deleted when I round the time in R?

I am importing a series of csv files into R. These contain a date/time column, id, and two columns of temperature values. This would give an example of what the data looks like: id<-c(1,2,3,4) date.time<-as.character(c("12/03/17 00:21:28",…
user97878
  • 53
  • 3
1
vote
1 answer

Add a vector of days and hours to plot in R

I would like to add concise date and time info to my plot in R. I am adding this plot to a research paper and when it's shrunk to fit the template it loses some of it's info. My actual datetime range is 20/07/2017 18:15 - 23/07/2017 21:15 I'd like…
TheGoat
  • 2,587
  • 3
  • 25
  • 58
1
vote
1 answer

Drops time when subtracting from POSIXlt object

I am trying to subtract an hour (3600 s) from this time object that is defined as 01:00. When I do so, the time component disappears, and I am left with the date only. I need to preserve the time component--how do I do so? This only happens when the…
SilvanD
  • 325
  • 2
  • 14
1
vote
1 answer

Using geom_rect with a time series in POSIXlt

I am using ggplot2 to make a simple two variable plot. My data set "Downstream" contains data from a downstream salinity probe and data from a hand-held conductivity meeter. I am using this plot to show the large amount of data missed by the…
Jbroome
  • 11
  • 1
1
vote
1 answer

R - xts object encountering character string is not in a standard unambiguous format

I was trying to replicate the momentum strategy by rbresearch with S&P 500 companies. However it turned out that getSymbols was not able to grab price data for all tickers and I only got around 300 stocks by using: getSymbols(symbols, src='yahoo',…
N_R
  • 31
  • 7
1
vote
2 answers

Converting from R POSIXlt to T-Sql datetime

I need to restructure the R POSIXlt object into an appropriate T-SQL query that is going to return a SQL datetime. I imagine there should be a way to conver the POSIXlt to a double and then use that double to make a SQL datetime, but I am not able…
doubleOK
  • 353
  • 6
  • 19
1
vote
0 answers

R: date formatting ignores timezone for POSIXlt objects

I cannot get R to format POSIXlt objects in the desired timezone. POSIXct works as expected. Is this a bug or am I missing something? date.str = "2015-12-09 13:30" from = "Europe/London" to = "America/Los_Angeles" lt = as.POSIXlt(date.str,…
Ilya Kolpakov
  • 196
  • 2
  • 8
1
vote
3 answers

Need to subset data frame by specific times using R

I have a data frame called summer.q.0 that contains time (X) and 4 temperatures (X0, X0.33, X0.66 and, X1). I need to subset the data frame extracting rows at specific times. Here is the head of my data frame: X X0 X0.33 …
skunkwerx
  • 11
  • 3
1
vote
0 answers

Error with date functions in data.table

I want to extract the date from a timestamp stored in R as a POSIXct class. e.g. > str(wdt$v_timestamp) POSIXct[1:15399], format: "2011-08-15 00:00:00" "2011-08-18 18:30:00" "2011-07-20 22:15:00" "2011-07-05 03:30:00" "2011-09-09 00:30:00" ... When…
drstevok
  • 715
  • 1
  • 6
  • 15
1
vote
1 answer

Convert Date String in Format "Mon Day, Year Time am/pm" to POSIXlt format in R?

I'm trying to convert a string to a date time. I can't even get R to recognize and format the month though. Here's a sample of the date formatting: > for(i in sample_times){print(i)} [1] "Aug 17, 2015 08:00 am" [1] "Aug 15, 2015 12:06 am" [1] "Jun…
goldisfine
  • 4,742
  • 11
  • 59
  • 83