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

Recall in date POSIXct

I couldn't find a solution of my problem with POSIXct format - I have a monthly data. This is a scrap of my code: Data <- as.POSIXct(as.character(czerwiec$Data), format = "%Y-%m-%d %H:%M:%S") get.rows <- Data >= as.POSIXct(as.character("2013-06-03…
Blazej
  • 19
  • 3
0
votes
1 answer

R - Error with axis call: (list) object cannot be coerced to type 'double'

I'd like to create a custom x-axis label like it was done here: http://blog.earlh.com/index.php/2009/07/plotting-with-custom-x-axis-labels-in-r-part-5-in-a-series/ But when I'm trying to set the x axis label with: at <- format(SubDateTime$DateTime,…
max.mustermann
  • 127
  • 1
  • 1
  • 9
0
votes
2 answers

difftime between 2 columns and next.row within a variable

Trying to caulculate the difference in time between two two columns, however time 2 in 'difftime' is in the next.row sample data: structure(list(code = c(10888, 10888, 10888, 10888, 10888, 10888, 10889, 10889, 10889, 10889, 10889, 10889, 10890,…
Salmo salar
  • 517
  • 1
  • 5
  • 17
0
votes
1 answer

Chron to POSIXct

I have a large dataset that in the first two columns contain the Date/Time information in character type. Date Time Current 1 28.02.2013 23:58:50 NA 2 28.02.2013 23:58:50 …
Tarigarma
  • 29
  • 1
  • 8
0
votes
1 answer

altering hours in posixct array in r

Say if I have an array that contains DateTimes: > head(DateTime) [1] "2010-04-23 13:00:00 UTC" "2010-04-23 14:00:00 UTC" "2010-04-23 15:00:00 UTC" [4] "2010-04-23 16:00:00 UTC" "2010-04-23 17:00:00 UTC" "2010-04-23 18:00:00 UTC" and another array…
user2355358
  • 81
  • 3
  • 7
0
votes
3 answers

Date time in write.csv in R

I am having data frame named "data" with following column > 2007-01-02 10:02:00 2007-01-02 10:03:00 2007-01-02 10:04:00 2007-01-02 10:05:00 2007-01-02 10:06:00 2007-01-02 10:07:00 When I save data using…
user1177819
  • 103
  • 1
  • 3
  • 7
0
votes
1 answer

unexpected output with POSIXct data

I have this df: > fechas <- c("1991-01-01", "1991-01-03", "1991-01-04", "1991-01-05", + "1991-01-08", "1991-01-09", "1991-01-11", "1991-01-13", "1991-01-15", + "1991-01-16", "1991-01-20", "1991-01-21",…
Miguel
  • 67
  • 2
  • 9
0
votes
3 answers

Problems adding a month to X using POSIXlt in R - need to reset value using as.Date(X)

This works for me in R: # Setting up the first inner while-loop controller, the start of the next water year NextH2OYear <- as.POSIXlt(firstDate) NextH2OYear$year <- NextH2OYear$year + 1 NextH2OYear<-as.Date(NextH2OYear) But this doesn't: #…
traggatmot
  • 1,423
  • 5
  • 26
  • 51
0
votes
1 answer

Optimizing search in time series data frame

I have a data frame of 50 columns by 2.5 million rows in R, representing a time series. The time column is of class POSIXct. For analysis, I repeatedly need to find the state of the system for a given class at a particular time. My current approach…
roelandvanbeek
  • 659
  • 8
  • 20
0
votes
0 answers

buildModel creates as.POSIXlt.character(x, tz, ...) error

I'm trying to rebuild this code. I've faced a lot of error but this one took my day. This is the command that produces the error. rf <- buildModel(data.model,method='randomForest', training.per=c(start(GSPC),index(GSPC["1999-12-31"])), …
Ulaş Şeker
  • 51
  • 2
  • 3
-1
votes
1 answer

How to get POSIXct to return a non-null value when converting a character string (with milliseconds) in R?

I am trying to convert the date-time character string "29.04.2023 06:08:01.165" using the POSIXct function, however I only get null values when I try to convert the whole thing: test <- "29.04.2023 06:08:01.165" z <- as.POSIXct(test,format="%d-%m-%Y…
-1
votes
1 answer

Data sampling before and after a timestamp

I have a data set from a sailing boat and I want to analyse some of the manoeuvres. Below is a data set with timestamps every second, a grouping column that groups by time of tack/manoeuvre and the other two (BSP,TWA) are variables. What I would…
TDaw
  • 203
  • 2
  • 11
-1
votes
1 answer

Change POSIXct format from YYYY-MM-DD to MM-DD-YYYY in R

New R user here. I import an xlxs using read_xlsx function. Two columns I read as date, the rest as text or numeric. After, I am unable to convert column "EDD" from YYYY-MM-DD to MM-DD-YYYY. Str shows POSIXct. MICAP <- read_xlsx("~/Copy of Joint…
-1
votes
1 answer

Selecting specific epochs in time series data using R

I have a datafile containing ~60,000 observations from 70 individuals. The datafile looks like this: datafile exampledatafile I wish to select the last 5 minutes of data for each individual. Each individual has a different number of observations. Is…
-1
votes
1 answer

Nas introcuded creating and xts object based on POSIXct object in R

I am trying to generate an xts objet based on intraday data of 5 min spam. The problem comes when transforming the date-time into a POSIXct object. By doing it, it activates the daylight saving time, and my format changes. When creating the object…
Victor
  • 1