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
-1
votes
1 answer

Is there a method to round date without memory exceed in r?

I am working on a dataset where I am rounding the posixct date to the nearest hour of one column of data.table with 88 mln rows. I used round. Date by base and round_date by lubridate, both of them exceeded memory, so could not finish. Finally, I…
Azat
  • 75
  • 6
-1
votes
1 answer

How to use scale_y_datetime with difftime data?

Is there a way to use scale_y_datetime() in a horizontally stacked barplot of cumulative durations? I have data of structured like this: x1 = as.POSIXct("2020-08-01 12:00") x2 = as.POSIXct("2020-08-01 16:00") df = tibble::tibble( x = seq(dt_start,…
Jonas Lindeløv
  • 5,442
  • 6
  • 31
  • 54
-1
votes
2 answers

How to create a specific week variable in R?

I have a dataframe with a datetime column in POSIXct format. I am aware that I can use the week() function in lubridate to obtain the specific week of the year that each datetime is occurring. For example, 2018-01-09 is in week 2 of the year.…
ljh2001
  • 391
  • 3
  • 17
-1
votes
1 answer

"Solved" Why ggplot2 will draw a "break"(shift) time-series line plot?

First of all, I would like to say sorry for your confusion to my description because of my poor English. I try to explain my question as my best, if you have anything that not understand please add a comment, I will explain with more details. The…
-1
votes
2 answers

Extract week number in POSIXlt

I am trying to create a "Week" column in my data and cannot figure out how to correctly assign the first day of the first week (starting on Sunday, December 30, 2018) to Week 1 of 2019. 12/30/2018 was a Sunday and I want to assign it to the first…
jrolfe
  • 25
  • 4
-1
votes
1 answer

Converting date column from factor into posixct makes my dataframe have a length and size of zero

I am trying to figure out a problem I'm having with converting a date column from factor to posixct. I have a script which I have run several times with no issue. When I read my .csv file, it has a date column which comes as a factor. But I convert…
-1
votes
1 answer

How to create a new variable excluding missing date values?

I am trying to write a R code for creating a new variable which excludes the missing date values from two variables, of class POSIXct/POSIXt. So, for example, if 'date1' and 'date2' are my two variables comprising mostly, of dates and some missing…
Bing96
  • 1
-1
votes
1 answer

Undesired NA's when merging Time and Date columns

I've the data below: > head(dataraw) GMT_DATE GMT_TIME LATITUDE LONGITUDE 1: 5/5/2016 13:00:30 -2.156247 35.44368 2: 5/5/2016 14:00:24 -2.202152 35.44438 3: 5/6/2016 05:02:48 -2.144972 35.56301 4: 5/6/2016 06:00:30 -2.257708 35.46812 5:…
juansalix
  • 503
  • 1
  • 8
  • 21
-1
votes
1 answer

as.POSIXct changing time to NA

When converting time in r using as.POSIXct converts all the values to NA. This is my code to do it: data1 %>% mutate(time_clean = ymd_hms(timestamp,tz = 'UTC')) %>% separate(time_clean, c('date', 'time'), sep = ' ') %>% mutate_at(vars(date),…
user5576922
  • 103
  • 1
  • 1
  • 7
-1
votes
1 answer

Converting the factor data to POSIXct format

The data is in factor format "2018-01-02T20:40:40.000Z" and I want it to be in POSIXct format "2018-01-02 20:40:40". How do I achieve this ?
Pal.s
  • 13
  • 5
-1
votes
1 answer

Do not know how to convert "dataframe" to class “POSIXct” on uBuntu 16.04

this time I tried to run my shiny application from shiny-server environment that i build on my uBuntu 16.04. the application code are like…
oRoberto
  • 165
  • 1
  • 11
-1
votes
1 answer

Week/year format as date in R

I have a data set dat with a year and a week variable (both integers). I want to combine them into a date POSIXct variable in R of the format W-YYYY. However, I get NA values when I use the as.POSIXct function. My code is…
lala_12
  • 131
  • 2
  • 10
-1
votes
1 answer

POSIXct from character returns NA

I have a time in excel that when converter to R, comes as a character and looks someting like this 0.59658. I am trying to convert to POSIXct but it returns as a POSIXct with NA. teste <- as.POSIXct(test, format = "%H:%M") I've also tried teste <-…
L8call
  • 87
  • 1
  • 1
  • 6
-1
votes
3 answers

Find time difference between highest and lowest value in data frame and sort by factor

I have a data frame and it looks like this: submition_id time_answered 2 2017-11-06 14:19:30 2 2017-11-06 14:22:45 2 2017-11-06 14:24:55 2 2017-11-06 14:34:10 4 2017-11-06 14:31:23 …
arezaie
  • 309
  • 2
  • 13
-1
votes
1 answer

Converting Excel times to POSIXct in r

I'm using an Excel dataset where the time values, MM:SS, come in numeric values that I need to convert to POSIXct in r and then make calculations. Below is sample data of what I have and I need to get dfOrig <- data.frame(StandarTime = …
user3357059
  • 1,122
  • 1
  • 15
  • 30