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

R: Transform factor to Datetime showing time as well

I have a factor column DATE in a dataframe a that shows dates written like this: 01/01/2012 00 It shows the day, the month, the year and the hour. On stackoverflow I found this way to transform from factor to datetime: a$DATE <-…
Pigna
  • 2,792
  • 5
  • 29
  • 51
0
votes
0 answers

posixct bug giving error for good date, good time, and good format

I made this code, and checked it and checked it, and I can't imagine why it gives me an error. Code: as.POSIXct(x = "2010-03-14 02:00:00", format ="%Y-%m-%d %H:%M:%S") Error: > as.POSIXct("2010-03-14 02:00:00", format = "%Y-%m-%d %H:%M:%S") [1]…
EngrStudent
  • 1,924
  • 31
  • 46
0
votes
3 answers

Subset records between timestamps

I have two data frames, trips which are unique trips taken by bikes that have a unique id, and intervals, which show the locations of bikes ids at every 10 minutes. My objective is to remove records from intervals if time falls in between start and…
iskandarblue
  • 7,208
  • 15
  • 60
  • 130
0
votes
0 answers

Extracting from data frame at specific time intervals ....index or posixct?

I currently have a dataframe which includes a running timeline of POSIXct (see below). Basically given a starting time of my choosing I want to be able to take rows at specific time interval. E.g. Say I start taking rows at four pm I then want to…
Dasr
  • 777
  • 6
  • 16
0
votes
2 answers

check if in GMT, then convert to local time in in GMT - R - looping

I've found a million posts about converting from GMT to local time, but not one that first checks if the date-time is in GMT, and then converting it to its representative local time. As folks are suggesting a duplicate, I am looking to convert from…
longlivebrew
  • 301
  • 3
  • 16
0
votes
0 answers

POSIXct - NA Value

I am trying to create a xts object (1 year, hourly data). The problem is, R does not let me use order.by, since there seems to be a random NA value in the vector I want to use to order. > x = read.csv(choose.files(), header=TRUE, sep=";") >…
shenflow
  • 345
  • 2
  • 12
0
votes
1 answer

creating time series data with repeating amounts that increase in regular intervals

The data I have deals with tests being run on electrical equipment with observations being 1 microsecond or 1/1,000,000 sec apart. The data stats when the test starts but when each observation happens. My boss wants me to add in two columns for the…
Chuck
  • 13
  • 1
0
votes
1 answer

as.POSXct returning NA

I'm trying to convert a string to a POSIXct object, but if I do this x <- as.POSIXct('15/10/17', tz = 'America/Sao_Paulo', format = '%d/%m/%y') the output is NA. I think that it occurs because it became daylight saving time in São Paulo on day…
Allan
  • 11
  • 1
0
votes
3 answers

data.table join with date

hello im trying to extract some id with a group and Date in range > d1 id group Date 1: 1 A 2017-07-02 2: 2 A 2017-07-04 3: 3 A 2017-05-15 4: 4 A 2017-08-02 5: 5 B 2017-12-28 6: 6 B 2015-07-02 7: 7 …
s.brunel
  • 1,003
  • 10
  • 24
0
votes
2 answers

R date time Count Breeding Time Per Hour

I'm sure it isn't hard to do but I cant find a way to sum up breeding time per hour. I have a couple thousands of event data (breeding) of birds that arrive on (AR) and leave from (LV) their nest. The corresponding times of arriving- and…
0
votes
1 answer

strptime() in R converts timestamp class from Posixct to character

When i strip date and time using strptime()it converts my time from class POSIXct to character. > head(data) timestamps value 1 2017-10-01 00:00:00 8.424 2 2017-10-01 01:00:00 7.832 3 2017-10-01 02:00:00 6.320 4 2017-10-01 03:00:00…
Jonreyan
  • 131
  • 2
  • 3
  • 14
0
votes
1 answer

Filter dataframe by time period and id in R

Problem: I am trying to filter my dataframe by specific datetimes that are dependent on an ID vector. Specifically, for observations where df$id == "A", I want to remove rows between 2017-08-05 00:20:00 and 2017-08-10 13:55:00. However, for…
philiporlando
  • 941
  • 4
  • 19
  • 31
0
votes
1 answer

Recursive ggplotting of POSIXct data with CORRECT corresponding plot name

need help: My original df has 50 vars: 49 POSIXct class and 1 categorical outcome var. I want to plot (ggplot) the 49 vars to explore its time distribution as a scatterplot. I want to put the plots into a grid of plots. The trouble is getting the…
saiful
  • 13
  • 4
0
votes
1 answer

R - Date/Time Calculations

My Question is divided into 2 parts: 1st part: I have a function, getdata() which I use to pull information for a date range. get_data <- function (fac_num, start_date, end_date) { if (!(is.null(fac_num) | is.null(start_date) |…
0
votes
2 answers

Adding Time Stamp to a date in R

Hi Have 2 columns in a dataframe. Column 1 has Dates like 2017-01-01 and column 2 has time stamp like 1:00 PM. I need to create another column that combines these 2 information and gives me the 2017-01-01 13:00:00
nityansh seth
  • 31
  • 2
  • 9