Re: [R] Problem with my function using as.POSIXct

2018-03-28 Thread Jeff Newmiller
You have succeeded, but you just don't know it. The POSIXct object is representing that instant of time internally... you are just complaining about how it is printing it. So convert it to character explicitly with the desired format when you want to print it. as.character( my.bastimeToSynoptic

[R] Problem with my function using as.POSIXct

2018-03-28 Thread Thomas Adams
Hello all: I wrote a function: my.bastimeToSynoptic <- function(x) { f<-unlist(strsplit(as.character(x), " ")) hr<-unlist(strsplit(f[2], ":")) if(as.numeric(hr[1])<6) { synoptic<-"00" } else { synoptic<-as.integer(as.numeric(hr[1])/6)*6 } tdate<-paste(c