Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update modification time of a file (touch)

Tags:

r

How do I touch a file (i.e., update its modification time without changing its contents) in R? I'm looking for a cross-platform built-in (or packaged) equivalent of:

system2("touch", file_name)
like image 686
krlmlr Avatar asked Jun 03 '15 01:06

krlmlr


1 Answers

I have found an implementation in the R.utils package, it utilizes the same pattern as suggested by @thelatemail but also offers vectorization and a fallback for R < 2.14, and invisibly returns the old timestamp:

R.utils::touchFile(file_name)

As usual, library(sos); ???touch was invaluable for finding this.

like image 195
krlmlr Avatar answered Sep 18 '22 11:09

krlmlr