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

maintaining date/POSIXct columns when Converting column class/types

I have a 400 column dataframe with multiple date columns interspersed. In the representative example below I would like to achieve the following: turn factors into numeric OR character OR POSIXct turn characters to numeric/integer where…
Moe
  • 131
  • 1
  • 9
0
votes
2 answers

R convert date, time and time zone strings to POSIXct

Date parsing bug I am having trouble with character to date-time conversions and would appreciate help understanding what is going wrong. To do this, I define a very simple data frame with two rows, which holds an ID, a time zone, a date, and a time…
PSz
  • 1
  • 1
0
votes
0 answers

Adjusting x axis on lattice levelplot when using a POSIXct

I have a level plot with a POSIXct axis, and I'd like to adjust how the date is displayed, as well as the number of ticks. My example plot looks like this: library(lattice) Beg<-as.POSIXct('2015-01-01 14:00:00',tz='UTC') End<-as.POSIXct('2015-01-10…
Vint
  • 413
  • 6
  • 17
0
votes
1 answer

as.Date not returning the date part from a POSIXt object

I am trying to get the date part of a date-time POSIXt object in R I get a number instead. Here is my data: y <- "2017-01-03 19:59:00" Using following code: as.Date(as.POSIXct(y)) I get this number: 17169. I am in Eastern Time Zone…
Fatima
  • 55
  • 6
0
votes
3 answers

R- Deleting rows by condition of one cell

im really new at R and i have a problem to solve. I have a dataframe like this str(data) Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 70128 obs. of 2 variables: $ date: POSIXct, format: "2009-01-01 00:00:00" "2009-01-01 01:00:00" "2009-01-01…
H.Maxi
  • 1
0
votes
3 answers

Fetching month and year from timestamps in R in a specific format and ordering them

The script arranges the patients3 data (attached in the package "bupaR" by the name patients) by the column patient and calculates the difference in corresponding timestamps in the time column, then the difference is displayed in seconds, minutes…
Robert J
  • 79
  • 6
0
votes
1 answer

Error: Invalid input: time_trans works with objects of class POSIXct only

I am trying to adjust the x axis in a graph using ggplot in R. My main reason for wanting to use scale_x_datetime is to have larger breaks in the graph. However, when I run the code, I get the following error: Error: Invalid input: time_trans works…
Brianna
  • 11
  • 1
  • 3
0
votes
0 answers

Preserving dates (posixct) in time series plots

The problem is that when i run ts(), the dates (Mean_Individual_data$Date) which are in posixct format gets converted to integers as shown in the graph via the link below. Are there any ways to preserve date-time format for the x-axis after passing…
Lacri Mosa
  • 159
  • 1
  • 10
0
votes
1 answer

posixct cannot read in time correctly

I'm having trouble with PosiXct in R. I have epoch timestamps in GMT and am trying to convert to US/Eastern. When I convert from epoch to timestamp, and specify tz = "GMT", R adds 4 fours to my time thinking I am converting from Eastern (where I…
longlivebrew
  • 301
  • 3
  • 16
0
votes
2 answers

Rounding time to the next milisecond

Consider the date: options(digits.secs = 6) library(lubridate) this_special_date <- with_tz(as.POSIXct(strptime('2017-11-20 23:00:00.051438000', '%Y-%m-%d %H:%M:%OS', tz = 'GMT')), …
user189035
  • 5,589
  • 13
  • 52
  • 112
0
votes
0 answers

as.POSIXct returns only the date, not the time

I have a database where I have a list of ocurrences with three sets of dates and times (total of six columns). I want to convert this to POSIX to manipulate later. The problem is that after creating three new columns to paste the date and time to a…
Hugo Torres
  • 308
  • 4
  • 13
0
votes
1 answer

How can I simplify my dplyr/apply script?

I want to go through several steps using a df which contains POSIXct datapoints. Essentially there are three columns in a dataframe which have different dates. The following needs to be achieved: change all dates to be the same for each row of the…
Dasr
  • 777
  • 6
  • 16
0
votes
1 answer

R apply to change date in Posixct?

I'm trying replace the date in some Posixct data I have in a df. Essentially I thought of using something like this: as.POSIXct(sub("\\S+", "2018-07-02", x)) x being the value in the row of my original data frame. I thought that the most efficient…
Dasr
  • 777
  • 6
  • 16
0
votes
0 answers

Add POSIXct timestamp legend in R

I have a data.frame with 3 variables and would like to plot two variables (VWC and Depth) related to the third one, Date, in POSIXct format. I would also like to add the POSIXct timestamp to the legend. The structure of my data.frame is the…
Raül Oo
  • 57
  • 8
0
votes
2 answers

Get POSIX date of the first day of week 53 (ISO convention)

I have date information given as - and I'd like to tell R "give me the POSIX dates of the first days for each of those weeks", how would I do that? I do get it working by pasting"-1" (for "1st day of week") to the vector of…
Rappster
  • 12,762
  • 7
  • 71
  • 120