Skip to content
Prev 277370 / 398506 Next

gsub help

Hi,

?I am working with the following list of files:

[1] "study_chr1.one.phased.impute2.chunk1"?????????????? 
[2] "study_chr1.one.phased.impute2.chunk1_info"????????? 
[3] "study_chr1.one.phased.impute2.chunk1_info_by_sample"
[4] "study_chr1.one.phased.impute2.chunk1_summary"?????? 
[5] "study_chr1.one.phased.impute2.chunk1_warnings"??????

The folder has many other files. I am trying to use gsub to give me just this file: study_chr1.one.phased.impute2.chunk1

With Uwe's help I have tried the following:

fls <- list.files(pattern="^study") # which gives me the list above.

ufls <- unique(gsub("(_.*)_.*", "\\1", fls))? # which outputs

[1] "study_chr1.one.phased.impute2.chunk1"??????? 
[2] "study_chr1.one.phased.impute2.chunk1_info_by"



I just want the file under [1] but can't seem to figure it out at this moment. Any help is appreciated.

Thanks,

Debs