I don't have R on the netbook I'm writing this from, but I *think* the following will work:
> 1. how can i only read in the files with the string patterns ggg or fff as > part of the file names? > for instance, I only need the file names with the ggg or fff in it > xxxxx_ggg_yyyyy_1.txt > yyyy_fff_yyyy_xxx.txt > > i don't need to read in the files, such as xxxx_aaa_yyyy.txt Maybe something like: d <- "C:\\FilesFolder\\" f <- list.files(path = d, pattern = "(ggg)|(fff)", full.names = TRUE) x <- lapply(f, read.table, header = TRUE) > 2.how cam rename the files: > > for instance: xxxxx_ggg_yyyyy_1.txt ======> changed to ggg1a.txt see ?file.rename > 3.after the files read in, how can i only keep the rows with the aaa and > bbb, everything elses show be removed from the files, but the files still > remain the same file name? > > for instance, in the xxxxx_ggg_yyyyy_1.txt file, it shouls looks like: > name count > > 1. aaa 100 > 2. bbb 2000 > 3. aaa 300 > 4. bbb 400 Something along the following lines should work: DF <- data.frame(name=rep(c("aaa", "bbb"), 2), count = c(100, 2000, 300, 400)) name count 1 aaa 100 2 bbb 2000 3 aaa 300 4 bbb 400 subset(DF, name == "aaa") name count 1 aaa 100 3 aaa 300 HTH Tony Breyal ______________________________________________ R-help@r-project.org mailing list 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.