posixlt

“unlist” removes class in list elements (POSIXlt) [duplicate]

陌路散爱 提交于 2019-12-10 15:17:07
问题 This question already has an answer here : why does unlist() kill dates in R (1 answer) Closed 2 years ago . I have an object that is a multi-level list, where all elements are of class POSIXlt : [[1]] [1] "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-15 GMT" [6] "2015-07-15 GMT" "2015-07-15 GMT" "2015-07-15 GMT" "2015-07-15 GMT" "2015-07-14 GMT" [11] "2015-07-14 GMT" "2015-07-14 GMT" "2015-07-14 GMT" "2015-07-14 GMT" "2015-07-14 GMT" [16] "2015-07-14 GMT" "2015

dplyr - mutate_each - colswise coercion to POSIXlt fails

风流意气都作罢 提交于 2019-12-05 22:53:23
I recently came across dplyr and - as a newbie - like it very much. Hence, I try to convert some of my base-R code into dplyr-code. Working with air traffic control data, I am struggling with coercing timestamps using lubridate and as.POSIXlt to parse timestamps embedded in a mutate_each() call. I need the POSIXlt format as I have to work with local times (at different locations) later on. Reading in the data delivers a data frame of characters. The following is a simplistic example: ICAO_ADEP <- c("DGAA","ZSPD","UAAA","RJTT","KJFK","WSSS") MVT_TIME_UTC <- c("01-Jan-2013 04:02:24", NA,"01-Jan

Integer to POSIXlt

百般思念 提交于 2019-12-02 04:11:12
I'm starting to get a handle on how base R handles dates/times, but still have some uncertainty. Using the following data set (exert from meteorological data), I was able to convert to POSIXct and POSIXlt using the as.character() function. The Date.Time is provided in the format yymmddhhmm. Date.Time <- c(1107151300, 1107151400, 1107151500, 1107151600, 1107151700, 1107151800) WindSpd <- c(11.8, 14.5, 14.9, 14.1, 15.2, 17.1) ##Using as.character()## #Note POSIXlt this time w <- data.frame(Date.Time, WindSpd) w$Date.Time <- as.POSIXlt(as.character(w$Date.Time), format = '%y%m%d%H%M', origin =

Converting to Local Time in R - Vector of Timezones

一笑奈何 提交于 2019-12-01 06:48:50
I have a set of data from across the US that I am trying to convert into local time for each "subject". I have UTC timestamps on each event and have converted those into POSIXct format, but every time I try to include a vector of tz = DS$Factor or tz = as.character(DS$Factor) in any of the POSIXct/POSIXlt functions (including format() and strftime() ) I get an error that says: Error in as.POSIXlt.POSIXct(x, tz = tz) : invalid 'tz' value If I just enter tz = 'US/Eastern' it works fine, but of course not all of my values are from that time zone. How do I get the time stamps into local time for

Converting chr “00:00:00” to date-time “00:00:00”

心已入冬 提交于 2019-11-30 17:38:18
问题 My question comes from this question. The question had the following character string. x <- "2007-02-01 00:00:00" y <- "02/01/2007 00:06:10" If you try to convert this string to date-class object, something funny happens. This is a sample from @nrusell's answer. as.POSIXct(x,tz=Sys.timezone()) [1] "2007-02-01 EST" as.POSIXct(y,format="%m/%d/%Y %H:%M:%S",tz=Sys.timezone()) [1] "2007-02-01 00:06:10 EST" As you see, 00:00:00 disappears from the first example. @Richard Scriven left the following

Problems with dplyr and POSIXlt data

邮差的信 提交于 2019-11-28 11:55:01
I have a problem. I downloaded data and tranformed dates into POSIXlt format df<-read.csv("007.csv", header=T, sep=";") df$transaction_date<-strptime(df$transaction_date, "%d.%m.%Y") df$install_date<-strptime(df$install_date, "%d.%m.%Y") df$days<- as.numeric(difftime(df$transaction_date,df$install_date, units = "days")) Data frame is about transaction in one online game. It contains value (its payment), transaction_date, intall_date and ID. I added new column, which showndays after installation. I tried to summarise data using dlyr df2<-df %>% group_by(days) %>% summarise(sum=sum(value)) And I

Convert Factor to Date/Time in R

自闭症网瘾萝莉.ら 提交于 2019-11-27 22:13:50
This is the information contained within my dataframe: ## minuteofday: factor w/ 89501 levels "2013-06-01 08:07:00",... ## dDdt: num 7.8564 2.318 ... ## minutes: POSIXlt, format: NA NA NA I need to convert the minute of day column to a date/time format: minuteave$minutes <- as.POSIXlt(as.character(minuteave$minuteofday), format="%m/%d/%Y %H:%M:%S") I've tried as.POSIXlt , as.POSIXct and as.Date . None of which worked. Does anyone have ANY thoughts. The goal is to plot minutes vs. dDdt, but it won't let me plot in the specified time period that I want to as a factor. I have no idea what to try

Convert Factor to Date/Time in R

不问归期 提交于 2019-11-26 20:56:12
问题 This is the information contained within my dataframe: ## minuteofday: factor w/ 89501 levels "2013-06-01 08:07:00",... ## dDdt: num 7.8564 2.318 ... ## minutes: POSIXlt, format: NA NA NA I need to convert the minute of day column to a date/time format: minuteave$minutes <- as.POSIXlt(as.character(minuteave$minuteofday), format="%m/%d/%Y %H:%M:%S") I've tried as.POSIXlt , as.POSIXct and as.Date . None of which worked. Does anyone have ANY thoughts. The goal is to plot minutes vs. dDdt, but it