Skip to content

Instantly share code, notes, and snippets.

@danielecook
Created June 18, 2014 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielecook/188f2a7c9cb15d52b8ee to your computer and use it in GitHub Desktop.
Save danielecook/188f2a7c9cb15d52b8ee to your computer and use it in GitHub Desktop.
In conjunction with included bash, concatenates multiple files within folders (with foldername and filename)
library(stringr)
library(dplyr)
"""
# Generate concatenated worm_track data using the following
for folder in `ls -d *\/`; do
for file in `ls $folder/worm*`; do
cat $file | awk -v file=$file '{print file","$1}' >> worm_track_all.txt
done;
done;
"""
names(worm_track_all) <- c("Folder","time","x","y","blps","mmps")
worm_track_all[,c("Folder", "Filename")] <- str_split_fixed(worm_track_all$Folder, "///",2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment