similar to: subset and as.POSIXct / as.POSIXlt oddness

Displaying 20 results from an estimated 10000 matches similar to: "subset and as.POSIXct / as.POSIXlt oddness"

2006 Sep 01
3
Date conversion with as.POSIXct and as.POSIXlt (PR#9196)
Full_Name: Erich Neuwirth Version: 2.3.1 OS: Windows XP, Linux Submission from: (NULL) (131.130.135.167) Converting Sys.Date() to a POSIX compliant time type in different ways produces inconsistent results: > Sys.date() [1] "2006-09-01" > as.POSIXct(Sys.Date()) [1] "2006-09-01 02:00:00 CEST" > as.POSIXlt(Sys.Date()) [1] "2006-09-01" >
2004 Oct 05
2
correct my method of estimating mean of two POSIXlt data frames
Hello, I searched the archives but could not come to a solution. I have to two columns of information t_start_cdt looks like: > t_start_cdt[1:4] [1] "2003-07-09 11:02:25" "2003-07-09 11:10:25" "2003-07-09 11:30:25" [4] "2003-07-09 12:00:25" > class(t_start_cdt) [1] "POSIXt" "POSIXlt" t_end_cdt looks like: > t_end_cdt[1:4]
2006 Nov 09
1
POSIXlt converted to POSIXct in as.data.frame()
In trying to use as.Date(), I've come across the conversion of POSIXlt to POSIXct when a POSIXlt variable is included in a data frame: my_POSIX <- strptime(c("11-09-2006", "11-10-2006", "11-11-2006", "11-12-2006", "11-13-2006"), "%m-%d-%Y") str(my_POSIX) my_Date <- as.Date(my_POSIX) str(my_Date) data <- format(my_Date)
2011 Mar 08
1
Date arithmetic coerces POSIXlt to POSIXct?
Hi. This feels like a bug to me, or at least an undocumented feature, but I thought I'd see what people here thought of it. Consider a POSIXlt object like this one: > a <- as.POSIXlt ("2011-01-23 12:45:45") > class (a) [1] "POSIXlt" "POSIXt" Fine. Now, if I do some arithmetic on that object, the result is converted to POSIXct. > class (a
2010 Jun 29
2
POSIXlt matching bug
I came across the below mis-feature/bug using match with POSIXlt objects (from strptime) in R 2.11.1 (though this appears to be an old issue). > x <- as.POSIXlt(Sys.Date()) > table <- as.POSIXlt(Sys.Date()+0:5) > length(x) [1] 1 > x %in% table # I expect TRUE [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > match(x, table) # I expect 1 [1] NA NA NA NA NA NA NA NA
2004 Feb 06
2
vector of factors to POSIXlt
hello, I have a vector of factors > str(rcptdt) Factor w/ 51 levels "1/10/03","1/13/03",..: > length(rcptdt) [1] 87 which i want to convert to class POSIXlt to extract the day, so: a1<-format(rcptdt,"%m/%d/%y") > length(a1) [1] 87 and: a2<-strptime(a1, "%m/%d/%y") str(a2) `POSIXlt', format: chr [1:87] "2002-04-18"
2006 Jul 23
1
diff, POSIXct, POSIXlt, POSIXt
Dear Listers, I have encountered a strange problem using diff() and POSIXt: dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006") dts <- strptime(dts, "%d/%m/%Y") class(dts) [1] "POSIXt"
2006 Jul 23
1
diff, POSIXct, POSIXlt, POSIXt
Dear Listers, I have encountered a strange problem using diff() and POSIXt: dts<-c("15/4/2003","15/7/2003","15/10/2003","15/04/2004","15/07/2004","15/10/2004","15/4/2005","15/07/2005","15/10/2005","15/4/2006") dts <- strptime(dts, "%d/%m/%Y") class(dts) [1] "POSIXt"
2015 Dec 07
2
inconsistency in POSIXlt
The documentation for the POSIXlt class states '"POSIXlt" objects will often have an attribute "tzone", a character vector of length 3 giving the time zone name from the TZ environment variable and the names of the base time zone and the alternate (daylight-saving) time zone. Sometimes this may just be of length one, giving the time zone
2012 Sep 05
2
POSIXlt and daylight savings time
I have a data frame that contains dates, but when I use as.POSIXlt() I lose the hours on all records. I traced this down to a particuar hour which causes the issue... > as.POSIXlt('2004-10-31 02:00:00') [1] "2004-10-31" > as.POSIXlt('2004-10-31 03:00:00') [1] "2004-10-31 03:00:00" How do I tell as.POSIXlt() to ignore daylight savings and just convert to
2012 Mar 28
1
POSIXlt vs POSIXct
Hello R users I am searching for a descriptive summary of the use of POSIXlt as compared to POSIXct date/time formats. I have been using them extensively for different purposes, but still can't quite understand when to use which one for the most efficient coding and use. I typically use them in graphics, comparison of times, interpolation of values between times, computation of
2007 Nov 01
1
daylight saving / time zone issues with as.POSIXlt/as.POSIXct (PR#10392)
Running under Windows XP 64 bit, as.POSIXlt()/as.POSIXct() seem to think that US time zones (EST5EDT, MST7MDT) switched from daylight savings back to standard time on Oct 28, 2007, whereas the switch is actually on Sun Nov 04, 2007. Examples: > Sys.timezone() [1] "Mountain Daylight Time" > as.POSIXct("2007-10-30 12:38:47") [1] "2007-10-30 12:38:47 Mountain
2010 Oct 28
1
Unexpected behabiour of min, tapply and POSIXct/POSIXlt classes?
Hello, I found rather surprising the behaviour of POSIXct and POSIXlt classes when combined with min and tapply. The details can be deduced from the script below: ############# Start of the script #################### before <- Sys.time() Sys.sleep( 1 ) now1 <- now2 <- Sys.time() my.times <- c( before, now1, now2 ) class( my.times ) ## [1] "POSIXct"
2012 Apr 05
3
Apply function to every 'nth' element of a vector
Dear R users, how do I e.g. square each second element of a vector with an even number of elements? Or more generally to apply a function to every 'nth' element of a vector. I looked into the apply functions, but found no hint. For example: v <- c(1, 2, 3, 4) mysquare <- function (x) { return (x*x) } w <- applyfun(v, mysquare, 2) then w should be c(1, 4, 3, 16) Thanks for
2012 Apr 14
1
simple read in with zoo using POSIXlt
Easy question a bit. So here's my code: http://pastebin.com/F4iQPVy5 I am trying to read in a series of timestamps. However with POSIXlt as FUN in read.zoo, the output is merely two numbers and is not the output that I'm hoping for. The code above should reproduce the error. Here is code that shows what I want it to do: http://pastebin.com/GEPZ5R9B The problem though, is that it's
2015 Aug 02
3
ayuda con análisis de supervivencia
Hola a todos, -Estoy estudiando el efecto de dos genotipos (~tratamientos) en la aparición de síndrome metabólico (MetS) con datos longitudinales recogidos a tiempo 0,7,10,15,20 y 25 años. -He hecho un dataframe con las siguientes variables MetS: Síndrome Metabólico (Si=1,No=0) bmi: Indice de masa corporal (IMC) cuando se produce la conversión a MetS+ . Para los que permancen MetS-, esta variable
2019 Aug 02
4
Infrequent but steady NULL-pointer caused segfault in as.POSIXlt.POSIXct (R 3.4.4)
The R script I run daily for hours looks like this: while (!finish) { Sys.sleep(0.1) time = as.integer(format(Sys.time(), "%H%M")) # always crash here if (new.data.timestamp() <= time) next # ... do some jobs for about 2 minutes ... gc() } Basically it waits for new data, which comes in every 10 minutes, and do some jobs, then gc(), then loop again. It
2009 Nov 19
6
Surprising length() of POSIXlt vector (PR#14073)
Arrays of POSIXlt dates always return a length of 9. This is correct (they're really lists of vectors of seconds, hours, and so forth), but other methods disguise them as flat vectors, giving superficially surprising behaviour: strings <- paste('2009-1-', 1:31, sep='') dates <- strptime(strings, format="%Y-%m-%d") print(dates) # [1]
2012 Jun 15
2
POSIXlt and trunc
Hi, I'm having trouble understanding how trunc is operating on vectors of POSIXlt objects. Why does dates[1:4] in the last line return a bunch of NAs even though dates look like it has all the right elements? This worries me that something is off with my use of trunc. Is trunc not suppose to be vectorized with POSIXlt? If not, then how should I truncate a bunch of POSIXlt objects? I'm
2011 Feb 18
1
problem with rbind when data frame contains an date-time variable "POSIXt" "POSIXlt"
I'm trying to rbind two data frames, both with the same columns names. One of the columns is a variable with date-time and this variable is causing the rbind to fail--giving the error "Error in names(value[[jj]])[ri] <- nm : 'names' attribute [7568] must be the same length as the vector [9]" Is there a way to stack or rbind these two data frames even with this extended