Kubke Lab:Research/ABR/Notebook/2014/01/12
Hearing development in barn owls | Main project page Previous entry Next entry |
General Entries
Personal EntriesFabianaHaving trouble with Knitr which seems to drop me back to the sandbox directory unless I put all the code togther - this could get annoying rnet --> <html>
<p>I) Create file list from directory</p> <p>1) Change directory to case #</p> <pre><code class="r">
setwd("~/Dropbox/OrisABR")
print("set wd to OrisABR") </code></pre> <pre><code>## [1] "set wd to OrisABR" </code></pre> <pre><code class="r">basedir <- getwd() print(basedir) </code></pre> <pre><code>## [1] "C:/Documents and Settings/mkub003.uoa/My Documents/Dropbox/OrisABR" </code></pre> <pre><code class="r">newdir <- readline("enter case number: ") </code></pre> <pre><code>## enter case number: </code></pre> <pre><code class="r">
newdir = "owl222"
casedir <- paste(basedir, "Analysis", "datafiles", newdir, sep = "/")
setwd(casedir) print(paste("you are now in", casedir)) </code></pre> <pre><code>## [1] "you are now in C:/Documents and Settings/mkub003.uoa/My Documents/Dropbox/OrisABR/Analysis/datafiles/owl222" </code></pre> <pre><code class="r">getwd() </code></pre> <pre><code>## [1] "C:/Documents and Settings/mkub003.uoa/My Documents/Dropbox/OrisABR/Analysis/datafiles/owl222" </code></pre> <pre><code class="r">
files <- dir() head(files) </code></pre> <pre><code>## [1] "222L01.LOG" "222L01.TXT" "222L02.LOG" "222L02.TXT" "222L03.LOG"
</code></pre> <pre><code class="r">
log <- regexpr("(.*)[L|l][O|o][G|g]", files) logfiles <- regmatches(files, log) length(logfiles) </code></pre> <pre><code>## [1] 16 </code></pre> <pre><code class="r">print(logfiles) </code></pre> <pre><code>## [1] "222L01.LOG" "222L02.LOG" "222L03.LOG" "222L04.LOG" "222L05.LOG"
</code></pre> <pre><code class="r"> txt <- regexpr("(.*)[T|t][X|x][T|t]", files) txtfiles <- regmatches(files, txt) length(txtfiles) </code></pre> <pre><code>## [1] 15 </code></pre> <pre><code class="r">print(txtfiles) </code></pre> <pre><code>## [1] "222L01.TXT" "222L02.TXT" "222L03.TXT" "222L04.TXT" "222L05.TXT"
</code></pre> <pre><code class="r">
<pre><code>## [1] 1000 24 </code></pre> <pre><code class="r">head(test) </code></pre> <pre><code>## msec left right spont bin.0 bin.1 bin.2 bin.3 bin.4 bin.5 bin.6 bin.7
</code></pre> <p>I am thinking at this point it might actually be easier to go through all of the file stacks and have them written all in a single format so that a single function can deal with all files rather than having to create a different bit of code to deal with each peccularity. </p> </body> </html> Andy
Oris
|