jennybc / here_here

I love the here package. Here's why.
313 stars 29 forks source link

Missing advantage of here #6

Open cportner opened 6 years ago

cportner commented 6 years ago

First, thank you for advertising "here". It makes it even easier to use relative paths. Second, one advantage of the package that you do not mention is that it becomes possible to do away with "paste0" commands for file names based on variables. Hence, it becomes possible to code something like this without having to mess around with "paste".

for (obs in 1:length(directory_list$name)) {

  # Get file name and Google Drive ID
  file_name <- directory_list$name[obs]
  file_id <- directory_list$id[obs]
  print(file_name)

  # Download file
  drive_download(
    as_id(file_id),
    path = here("data", file_name),
    overwrite = TRUE
  )
}

If you think it worthwhile, I can write up a smaller version of this and add it. If you think it would distract from the central message, that is fine too.

francisbarton commented 5 years ago

I think this is a good advantage to note. Very neat. The text is not especially long at present and I think your example could be added, but that is up to the owner. I have given your idea a +1 fwiw.

liuyanguu commented 5 years ago

I have been using here for a while. Indeed when I recommend this package to others I was not very sure what are the overwhelming advantages. Since if operating within a project, the directory to files is already very simple.

francisbarton commented 5 years ago

You're right, if your project just stays in one folder and all your files are in a stable location within or under that folder. I think here() comes into its own when you want to use sub-folders and use setwd(); here helps you avoid "../" relative reference paths as well as avoiding non-portable fixed file paths. https://twitter.com/ludictech/status/1164867065733423104