The code below combines the three files and then creates a plot function that plots a variable x vs. time with three panels, one for each data set. My initial thought was to put them into one plot with a color aesthetic, but decided that individual panels might be better. You can always edit the plot function to get what you need. I tried it on a subset of the variables in the combined data frame and it seemed to work for me (Win7, R-2.13.1patched, ggplot 0.8.9, plyr 1.6).
I unpacked your tar.gz file in my R starting directory; each file started with 'week', so that's where we'll begin.
files <- list.files(pattern = '^week')
# Function to read a particular file
readfun <- function(x) read.table(x, header = TRUE, sep = '\t',
stringsAsFactors = FALSE)
# Apply readfun() to all files in the list and rbind them
colormrg <- do.call('rbind', lapply(files, readfun))
# Create two new variables:
# - type, to distinguish the different data sets
# - DATETIME, to generate a POSIXct time variable
# We could use transform() or within() here, but let's
# use the mutate() function from plyr instead:
colormrg <- mutate(colormrg,
type = rep(c('allcolor', 'color1', 'color2'),
sapply(jlist, nrow)),
DATETIME = as.POSIXct(paste(DATE_fl, TIME_fl),
format = '%m/%d/%Y %H:%M:%S'))
# Generate a vector of variable names to be plotted:
# (feel free to change this - I used all but the obvious exceptions)
nms <- names(colormrg)[-c(1:3, 23, 37:39)]
# Function to create the plot and export it to a pdf file
# argument is a quoted variable name
# aes_string allows one to insert character strings to represent arguments
# I used 12 hour gaps to avoid overplotting of date-time labels and used
# mo/xx instead of 'Mon xx' to save on space
# You may want to use breaks = in the scale_x_datetime() call to set up
# different labeling points.
plotfun <- function(var) {
print(ggplot(colormrg, aes_string(x = 'DATETIME', y = var)) +
geom_point() +
labs(x = 'Time', y = "") +
opts(title = var) +
facet_wrap(~ type, ncol = 1) +
scale_x_datetime(
major = '12 hours',
limits = c(as.POSIXct('2011-09-01 20:00:00'),
as.POSIXct('2011-09-07 12:00:00')),
format = '%m/%d\n%H:%M')
)
ggsave(paste(var, 'pdf', sep = '.'))
invisible()
}
# This is plyr's version of mapply(); the idea is to generate a plot
# for each variable in the vector nms.
# The _ means don't return anything - the plot is the 'side effect' output
# Expect this to take a couple of minutes...
m_ply(nms, plotfun)
HTH,
Dennis