Results of file.info if file doesn't exist

I clearly don't understand what file.info() returns when a file doesn't exist. How come "z.mtime not found" rather than it's an NA?

> z <- file.info("foo")
> z
    size isdir mode mtime ctime atime  exe
foo   NA    NA <NA>  <NA>  <NA>  <NA> <NA>
> is.na(z.mtime)
Error: object 'z.mtime' not found

Get the column with $ not .

z <- file.info("foo")
z
#>     size isdir mode mtime ctime atime  exe
#> foo   NA    NA <NA>  <NA>  <NA>  <NA> <NA>
z$mtime
#> [1] NA

Created on 2024-05-15 with reprex v2.0.2

1 Like