Hi,

I am new to R so forgive me if the following query is somewhat simple.  I have a small tab-separated file with n records of glucose values, one record per day, seven measurements per day. It looks like this:

date    sober    no    vm    nm    va    na    vs
20091229    NA    6.8    NA    2.7    11.7    2.7    6.2

I'd like to make a graph on which the glucose day curves are plotted separately for each day. I'm sure I'll be able to make it pretty (such as labelling, etc), but yesterday I've been struggling just a bit too long to get the basics right. Here's what I've got till sofar:

file = "d:/temp/glucose.tab"
glucose <- read.table(file, header=TRUE, sep="\t", row.names="datum") #
# Not sure if I got the row.names correct, I may need to use as.character (I believe I did use #that in the interactive session).
attach(glucose)
summary(glucose)

ncol <- length(names(glucose))
xrange <- range(1, ncol)
yrange <- range(0, max(!is.na(glucose[1:ncol])))

nrecs <- nrow(glucose)
colors <- rainbow(nrecs)
linetype <- c(1:nrecs)
plot(xrange, yrange, type="n", xlab="Measurement moment",  ylab="Glucose (mmol/liter)")
for (i in 1: nrecs) {
  daily_values <- glucose[i,]
  lines(daily_values, type="b", lwd=1.5, lty=linetype[i], col=colors[i]) 
}

So I want to loop over the file and add the plot lines one by one (day by day), but it seems that something's not yet right because nothing appears on the graph. Can anybody give me some pointers? Thank you in advance


Cheers!!

Albert-Jan



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the face of ambiguity, refuse the temptation to guess.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


      
	[[alternative HTML version deleted]]

