Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I have a set of html files which are generated as a output. The names of the html output files should be the timestamps. I am able to generate the date using the following code.

DT::SaveWidget(Output, paste0(Sys.date(), ".html"))

I want the time as well. But I get an error "Cannot create file, reason: 'Invalid argument'"

DT::SaveWidget(Output, paste0(Sys.time(), ".html"))

I also tried the following way:

now <- Sys.time() 

DT :: SaveWidget(Output,paste0(now, "%Y%m%d_%H%M%S_"), ".html")

It is throwing the same error. Is there a way to append the time to the html output files. It is for a set of files in folder. So, it should be different for each file. Kindly suggest a way to do this.

1 Answer

0 votes
by (41.4k points)

 You can use this:

htmlwidgets::SaveWidget(Output, paste0(format(Sys.time(), "%Y_%m_%d__%H_%M_%S"), ".html"))

Browse Categories

...