You're right. When I use the default, it does clean up the temporary file, but it does
not clean up the temporary directory after closing R. For example, after closing R, there is still the directory hdfs://tmp/Rtmp7JDOsb on HDFS (although the file in that was contained in it has been cleaned up, i.e. deleted).
Furthermore, what I have noticed for the default is that it always uses the same directory name (e.g. hdfs://tmp/Rtmp7JDOsb in my case), although that should not happen. This is inconsistent with tempdir(), which should give a random directory name that should be different each time it is called.
If the above issues could be fixed, then my custom example above should probably be modified like this to make it more consistent with the default behavior:
library("rmr2")
rmr.options(dfs.tempdir = paste0("/user/me/tmp-RHadoop/", basename(tempdir())))
big.data.object <- to.dfs(1:12)