0

I am trying to do a very simple rbind with a series of csvs in a folder and keep having my permission denied. I just did this same code yesterday but it is not working today and I tried restarting R.

Here is my code:

fp<-"C:/Users/dsmith2/OneDrive - TPWD/Desktop/LMB Telemetry/R/WDMay23/merge/TB"
df <- do.call(rbind,lapply(fp,read.csv))

Why is my permission denied? I don't have any csvs open when I am trying to do this and get this error:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:/Users/dsmith2/OneDrive - TPWD/Desktop/LMB Telemetry/R/WDMay23/merge/TB': Permission denied
r2evans
  • 141,215
  • 6
  • 77
  • 149
David Smith
  • 305
  • 1
  • 8
  • If TB is a csv file, try adding `.csv` at the end of your path. – Godrim May 11 '23 at 14:16
  • TB is the folder that the csvs are in – David Smith May 11 '23 at 14:20
  • 1
    Your use of `lapply(fp, read.csv)` suggests that `fp` should be a vector or list of files, but your string assignment suggests that that might be a _directory_ instead. Try `fp <- list.files("C:/Users/.../TB", full.names=TRUE, pattern="csv$")`. – r2evans May 11 '23 at 14:20

0 Answers0