using list.files() in R to find files that start with a specific string
<p>I am using <code>list.files()</code> in r to read in files. However, the <code>pattern=</code> input will scan all files that contain that special string I am scanning for...</p>

<p>Ex. </p>

<p><code>MASTERLIST =list.files("/Volumes/3TB/",pattern="CL")</code></p>

<p>will call in the following files: </p>

<pre><code>[1] "CLF16"  "CLF17"  "CLF18"  "CLF19"  "CLG16"  "CLG17"  "CLG18"  "CLH16"  "CLH17"  "CLJ16"  "CLJ17"  "CLK16"  "CLK17"  "CLK18"  "CLM16"  "CLM17" 
[17] "CLM18"  "CLM19"  "CLN16"  "CLN17"  "CLQ16"  "CLQ17"  "CLU15"  "CLU16"  "CLU17"  "CLV15"  "CLV16"  "CLV17"  "CLX15"  "CLX16"  "CLX17"  "CLZ15" 
[33] "CLZ16"  "CLZ17"  "CLZ18"  "CLZ19"  "CLZ20"  "MCLH16" "MCLM16" "MCLU16" "MCLZ16"
</code></pre>

<p>But I only want those files that begin with <code>CL</code> and not every file that contains <code>CL</code> like files 38 through 41 </p>

<p>How do I get it to call only those files that begin that pattern?</p>