Changing File Names In R
1
Hey
i am trying to change the file names. I have like 86 files and used list.files(path="...") to get a charachter vector of file names.
exon_counts__htseq__20130607-H23761_2_L7.D702.counts
exon_counts__htseq__20130607-H23761_7B1_L7.D702.counts
exon_counts__htseq__20130607-H23761_105_L7.D702.counts
exon_counts__htseq__20130607-H23761_23_L7.D702.counts
the file names are like these.. i know in R file.rename(from=from.files, to=to.files) this function is used to rename the files. But i want to have the file names just as 2.counts, 7B1.counts, 105.counts, 23.counts
Wil be thankyou if you can help
r
• 3.4k views
•
link
updated 10.7 years ago by
Michael
55k
•
written 10.7 years ago by
HNK
▴
150
> gsub("^.+_([^_]+)_[^_]+.counts","\\1.counts",c("exon_counts__htseq__20130607-H23761_2_L7.D702.counts","exon_counts__htseq__20130607-H23761_7B1_L7.D702.counts","exon_counts__htseq__20130607-H23761_105_L7.D702.counts","exon_counts__htseq__20130607-H23761_23_L7.D702.counts"))
[1] "2.counts" "7B1.counts" "105.counts" "23.counts"
However, do you know stackoverflow is more appropriate for such questions?
•
link
10.7 years ago by
xb
▴
420
Login before adding your answer.
Traffic: 1768 users visited in the last hour
Thakuuu soo much :)