On Thu, 29 Jan 2004 11:33:25 -0300, Marcelo Luiz de Laia <[EMAIL PROTECTED]> wrote :
>Hi All, > >I have a very simple problem. I have several files in a same directory. I would like >to send for an object only the files that finish in ".sens.". I execute the command >below, > >files <- dir(pattern="*.sens") > >but it includes all of the files that have "sens", independent of they be in the end >or in the middle of the name of the file. How could I solve this? I sought in the >html_help but I didn't find similar to this. > >My files > >"script_sens.txt", "Sen_155_01_R1.sens", "Sen_155_01_R2.sens", "Sen_155_01_R3.sens", >"Sen_155_02_R1.sens", "Sen_155_02_R2.sens", "Sen_155_02_R3.sens", >"Sen_155_03_R1.sens", "Sen_155_03_R2.sens", "Sen_155_03_R3.sens", >"tome2sens_time1sens.txt" The pattern in dir() is a regular expression pattern, not a filename wildcard. You want dir(pattern="\\.sens$"). (The double backslash comes because the regular expression you want contains a backslash before the dot.) If you're using Windows, the choose.files() interactive function is probably more friendly. There choose.files('*.sens') works the way you're expecting (except it's interactive). Duncan Murdoch ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html