I'm trying to rename files in a WD folder from RStudio. The files are named with IDs and I want to replace the IDs with names. I have a reference file which is a dataframe(urban_o) with supplierID, companyname, and vendornumber. I tried this for loop but it doesn't seem to work. Error - the condition has length > 1 and only the first element will be used. Any ideas where I'm getting it wrong?
original_names <- list.files()
urba_o <- import("C:\Users\MaangiJ\Downloads\urba_o.xlsx")
# for loop
for (x in original_names){
if(x == urba_o$supplierid[]){
file.rename(x,urba_o$CompanyName[])
}
}