They are identical in the sense that they accept the same arguments, these arguments have the same default values, and they use the same function .Internalto execute.
As pointed out in the comments by @RichScriven in the comments, a compact and accurate test that they are the same can be run with identical:
identical(list.files, dir)
[1] TRUE
We can also take a look at their source code.
dir
function (path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE,
recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE,
no.. = FALSE)
.Internal(list.files(path, pattern, all.files, full.names, recursive,
ignore.case, include.dirs, no..))
<bytecode: 0x000000000fe1c388>
<environment: namespace:base>
and
list.files
function (path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE,
recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE,
no.. = FALSE)
.Internal(list.files(path, pattern, all.files, full.names, recursive,
ignore.case, include.dirs, no..))
<bytecode: 0x0000000008811280>
<environment: namespace:base>
note that
.Internal(list.files(path, pattern, all.files, full.names, recursive,
ignore.case, include.dirs, no..))
performed in both functions.