[R] rename files in R

Kai Yang y@ngk@|9999 @end|ng |rom y@hoo@com
Fri Sep 16 19:51:49 CEST 2022

 Hello,Here is the example:  
  file name    first row  file1.txt     abc.txt  file2.txt     bed.txt  file3.txt     gogo.txt  . . file1243.txt    last.txt    
I want to use loop because I need to read the first row information for first file, and then rename the file, then go to next file. I'm not sure if this is right way to approach my goal. Any suggestion will be appreciated. Thanks, Kai    On Friday, September 16, 2022 at 10:38:32 AM PDT, Rui Barradas <ruipbarradas using sapo.pt> wrote:  

Please post the first row of 2 or 3 files and the expected result.

You can rename files with ?file.rename. This function is vectorized its 
on arguments so you do not need a loop, only the source and destination 
filenames. Both vectors should have the same length, if not strange 
things will occur including data loss.

Hope this helps,

Rui Barradas

Às 18:26 de 16/09/2022, Kai Yang via R-help escreveu:
> Hello,I have a lot of files with not meaningful name, such as:  file1.txt, file2.txt ...... I need to rename them using the information from the first row of the files. Now I can get the information from the first row of each file. Now, I need know how to rename them in R (using loop?). Thank you for your helpKai
>     [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
	[[alternative HTML version deleted]]

More information about the R-help mailing list