find the creation date of a file in r

To find the creation date of a file in R, you can use the file.info() function to get the file attributes, and then extract the creation time from the resulting object using the attr() function with the ctime attribute:

main.r
file_path <- "path/to/file"
file_info <- file.info(file_path)
creation_date <- attr(file_info, "ctime")
104 chars
4 lines

This will give you the creation date and time of the file as a POSIXct object. If you want to format the date in a specific way, you can use the format() function:

main.r
formatted_date <- format(creation_date, format = "%Y-%m-%d %H:%M:%S")
70 chars
2 lines

This will give you the date in the format "YYYY-MM-DD HH:MM:SS".

gistlibby LogSnag