On 2025-11-14 12:47 p.m., Iris Simmons wrote:
R does this for convenience when printing values. But it's not always
convenient when writing to a file. Instead, you could use strftime to
convert to your desired character format before writing:
mydf$data_POSIX <- strftime(mydf$data_POSIX, "%Y-%m-%d %H:%M:%OS3")
you can optionally change the 3 to a number between 0 and 6. If you choose
0, it's easier to just use %S instead.
That can happen automatically if you set an as.character() method:
as.character.POSIXct <- function(x, ...) strftime(x, "%Y-%m-%d
%H:%M:%OS3")
(By default, there's a POSIXt method, but no POSIXct method.)
Time zone issues still make mydf2 different from mydf, but you won't get
NAs.
Duncan Murdoch
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.