File extension renaming in R
问题 I am just trying to change the filename extensions to .doc. I'm trying the code below but it does not work. How come? I'm using instructions from here startingDir<-"C:/Data/SCRIPTS/R/TextMining/myData" filez<-list.files(startingDir) sapply(filez,FUN=function(eachPath){ file.rename(from=eachPath,to=sub(pattern =".LOG",replacement=".DOC",eachPath)) }) The output I get is: DD17-01.LOG DD17-02.LOG DD17-03.LOG DD17-4.LOG DD17-5.LOG DD37-01.LOG DD37-02.LOG DD39-01.LOG DD39-02.LOG DD39-03.LOG FALSE