Thakuuu soo much :)
Changing File Names In R
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
• 3,823 views
•
link
1 answer
> 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?
• 36 views
•
link
• 0 views
•
link
Log in to answer this question.