Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting numbers out of sys.time

is there a more efficient/elegant method of doing the following in which I concatenate all the numbers in the output of the Sys.time() output

x <- as.character(Sys.time())
paste0(substr(x,0,4),substr(x,6,7),substr(x,9,10),substr(x,12,13),substr(x,15,16),substr(x,18,20))

It probably includes paste and collapse somehow but not sure how to do it...

like image 293
h.l.m Avatar asked Jan 23 '26 18:01

h.l.m


1 Answers

I would have thought format to be the first choice:

format(Sys.time(), "%Y%m%d%H%M%S")
[1] "20120909231732"
like image 57
IRTFM Avatar answered Jan 26 '26 09:01

IRTFM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!