Off topic:Rename Files In Subfolders In R
0
1
Entering edit mode
10.6 years ago
Jason ▴ 20

I have a folder "Samples" with sub-folders named "A01" to "A11". Each folder contains 2 files i.e. probes.txt and snps.txt. I want to write a code that reads the subfolders names, go into each subfolder and rename the 2 text files with the subfolder name in it e.g. A01_probes.txt

I wrote this code and R and I can't work out what's the problem. For me, the length of both "from" and "to" are same!

Help!


for (i in 1:length(b))
{
  setwd(b[i])
  vr1<-cat(basename(b[i]),"pro.txt",sep="")
  vr2<-cat(basename(b[i]),"s.txt",sep="")
  file.rename("probes.txt",paste(vr1))
  file.rename("snps.txt",paste(vr2))
}

Error in file.rename("probes.txt", paste(vr1)) : 'from' and 'to' are of different lengths

r • 7.1k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3252 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6