find the last modified date of a directory in r

To find the last modified date of a directory in R, you can use the file.info() function to get information about the directory, including its modification date. Here's an example:

main.r
# Set the path of the directory you want to check
dir_path <- "/path/to/directory"

# Use file.info() to get information about the directory
dir_info <- file.info(dir_path)

# Get the modification date of the directory as a POSIXct object
mod_date <- dir_info$mtime

# Print the modification date
mod_date
306 chars
12 lines

In this example, dir_path is the path of the directory you want to check. The file.info() function returns a list of properties for the specified file or directory, including the modification time (mtime). We store this list of properties in dir_info. The mtime property is stored as a POSIXct object, which represents a date and time. We can access this object using the $ operator and store it in mod_date. Finally, we print mod_date to see the modification date of the directory.

gistlibby LogSnag