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

Expand Time Into Minutes Increments

I'm trying to expand time into minute increments from tstart to tstop: ## Make reproducible example > dput(df) structure(list(id = c(101, 101, 101, 101, 101, 101, 101, 104, 104, 104, 104, 104, 104, 104, 104), tstart = structure(c(1427191679,…
Thomas Speidel
  • 1,369
  • 1
  • 14
  • 26
0
votes
1 answer

How to read out a CET/CEST time series from Excel with R when DST daylight saving time is cause of repeated timestamps?

I have the follwing Excel inputs from an electricity provider... column: Excel's time differences between values in 2. column column: Datetimes given by the Swiss electricity provider obviously in CET/CEST format column: datetimes in Excel…
NanisTe
  • 13
  • 4
0
votes
3 answers

Grouping posixct-data non-linear

I have got a series of video uploads and I want to show how many videos has been uploaded in the last month, half year, year, 2, year, 3, year ... PUBLISHED_AT is of type posixct and should be transformed into factor with the levels above. Is there…
barracuda317
  • 608
  • 7
  • 24
0
votes
1 answer

R - conversion from chr to POSIXct date/time format in imported csv file ends in N/A

I have imported a csv file (excel) with a timestamp and value. All my efforts to convert the timestamp column to usable time in R result in N/A. I have looked at several threads (SO and elsewhere) and tried many suggestions but somehow not managed…
bjarg
  • 27
  • 5
0
votes
0 answers

cut.POSIXt: Why isn't POSIXct a date-time object?

(I've read many similar problems, but could not find an answer to my problem, even though it seems trivial; I just don't see the cause of the problem) I have time-stamped measurements (with some offset-based numeric timestamps), and I want to…
U. Windl
  • 3,480
  • 26
  • 54
0
votes
0 answers

changing timezone of a column in a data frame to different timezones

I have the following data frame: time_df=data.frame(id=c(1,2,3,4,5,6,7), …
chessosapiens
  • 3,159
  • 10
  • 36
  • 58
0
votes
0 answers

Format time in R

I'm new to R, but need help formatting just one variable in my data frame: > str(g.2015.1990$START.TIME) int [1:60464] 712 606 1238 708 709 707 407 707 612 1237 ... Although R interprets this as an integer, it is a time variable formatted in 3-4…
0
votes
1 answer

Setorder using data table, not working for posixct milliseconds

I would like to sort my data table after time using setorder. library(data.table) DT <- data.table(timestamp=c(as.POSIXct("2013-01-01 17:54:23.577"), as.POSIXct("2013-01-01 17:54:23.568"), …
johnblund
  • 402
  • 5
  • 21
0
votes
1 answer

Predictive power of date variable reduces when changed from as.Date to as.numeric

I'm building a regression model with several date and numeric variables. I do a quick check on one of the date variables lm.fit = lm(label ~ Firstday, data = rawdata) summary(lm.fit)$r.squared to gauge its predictive influence on the…
Mikee
  • 783
  • 1
  • 6
  • 18
0
votes
1 answer

Time difference of successive rows in hours in r

I have the following data frame id day total_amount new (int) (fctr) (int) (dfft) 1 1 2015-07-09 1000 105 days 2 1 2015-10-22 100 21 days 3 1 2015-11-12 200 15 days 4 …
chessosapiens
  • 3,159
  • 10
  • 36
  • 58
0
votes
1 answer

Fill in gaps by merging with dataframe which is complete?

I am trying to complete a dataframe which has gaps. The data is structured hourly and there are some jumps between hours. This is a sample of the dataframe: sms <- read.csv("hoursms2.csv", sep = ";", header = FALSE) sms$date <-…
adrian1121
  • 904
  • 2
  • 9
  • 21
0
votes
2 answers

How can I assign the value from one of two POSIXct columns in a data.frame to a new POSIXct column?

I have a data.frame with two columns of type POSIXct, though for every row, only one column will have a value, e.g., dd <- data.frame(date1 = c(now(), NA), date2 = c(as.POSIXct(NA), now())) > dd date1 date2 1…
matmat
  • 875
  • 8
  • 11
0
votes
0 answers

How to either calculate with POSIXlt or convert POSIXlt class into POSIXct in R?

I was trying to find an answer to my question as mentioned above. I am trying to calculate the minutes difference between datetime formated cells in two separate columns. However, the input is already in POSIXlt and it seams (for me also…
0
votes
1 answer

Change Format of Date Column

I need to turn one date format into another with RStudio, since for lubridate and other date related functions a standard unambiguous format is needed for further work. I've included a few examples and informations…
BrahminXy
  • 11
  • 3
0
votes
2 answers

R Labeling multiple date periods in a POSIXlt date sequence

I am working in R. I have a date sequence and I would like assign whether each particular date is term time or a school holiday. I plan to do this using a dataframe column where each row is labelled "Holiday" or "Term" My approach is to create a…
alkey
  • 986
  • 4
  • 16
  • 33