[Rd] Suggestion for comments in data files (i.e. read.table)

Telford Tendys telford@progsoc.uts.edu.au
Tue, 23 May 2000 11:26:05 +1000

I realise that there is an existing system for documenting datasets
but what I would like is to be able to whack a few lines of commentary
at the top of a file which contains data -- not full documentation but
just an outline for myself to remind me of what I was doing or what
settings I was using, etc.

I was thinking that the read.table() function might be extended to
support an option allowing it to throw away lines that begin with
the # character (same comment character as R source, shell script, perl, etc)
thus allowing data files with comments added to them. For example:

# Testing the force of my linear motor
# v = supply voltage (reading from built-in meter on bench supply)
# x = distance of movement (NA indicates that bar was dropped)
# m = mass of bar
"v" "x" "m"
 1   2   3
 4   5   6
 7   8   9
# I might have bumped the table for this one
10  NA  12


Then you can load it up with:

mytable <- read.table( "data", header=TRUE, comment=TRUE )

and then proceed as normal.

I'm sure it would be a very small change, if other people think
it might be useful then I'll try and make a patch to support it.

	- Tel

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch