-1

I've picked up some old code off someone (cannot ask them directly) and they have the following code

setwd(dirname(getActiveDocumentContext()$path))

dataset= fread("../Folder/excel_file.csv", stringsAsFactors = FALSE)

I am wondering how fread knows what the ".." is? I assume the directory has been set in the first line, however I don't know how to interpret it as I need to change the directory that it currently reads from.

When I run getwd() it shows me a file path that doesnt even have excel_file.csv but when I run that line it successfully imports the dataset so I am entirely confused. Any assistance would be greatly appreciated thank you

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
MuzzMan123
  • 17
  • 4
  • 2
    The `..` means parent directory, so one level up from the working directory. Note this is a standard convention, not something specific to `fread()`. Compare, for example, `list.files()` and `list.files("..")`. – Ritchie Sacramento Aug 11 '23 at 02:26
  • Heck , the meaning of `../` is not even specific to `R` . It's pretty much standard for nearly all OSes in current use. – Carl Witthoft Aug 11 '23 at 13:35
  • 1
    hi - In the future, please list all libraries you are using. In this case, at the very least, I'm guessing you are using `data.table::fread` but don't make us guess. – Carl Witthoft Aug 11 '23 at 13:36

0 Answers0