I have a few files in a folder and their column headers are all the same.
I just want to go into each one and delete one record. It's a mystery record that causes everything to screw up.
Anyhow, I want to filter for [Record] == 1 and the delete it and write over the file without opening each one and doing this manually.
I have the below code, I think it's the writing the output part that's causing me some headaches.
files = dir_ls(glob = "Book*") #where I have my files
fX_delete = function(X){
read_csv(X) %>% #reading the file
filter(Record <> 1) %>% #filtering out the mystery record
write.csv( paste0(glue{files}&".csv")) #writing the output
}
map(files,fX_delete) # using map to iterate
the error message I got is
Error in X & ".csv" :
operations are possible only for numeric, logical or complex types
any help is appreciated!