I am trying to read multiple .csv files but within a function with a single input variable, so I can modify each file with the same of lines of code. All my files (All_0320, Part_0320, etc.) are located in the same folder.
func1 <- function(file){
setwd("C:/Users/Myname/FolderWithData/")
z1 <- read.csv(paste0(file,".csv",sep=""))
#lines of code that modify z1
return(z1)
}
num1 <- func1(All_0320)
num2 <- func1(Part_0320)
This gives me an error " Error in file(file, "rt") : invalid 'description' argument "
What am I doing wrong?
I used the code from here as an example: Doing Macros in R