[R] data file with columns of unequal length

Jim Lemon jim at bitwrit.com.au
Fri Oct 23 13:32:30 CEST 2009


On 10/23/2009 10:07 PM, William Simpson wrote:
> Thanks Jim. BTW the times in x and y are in ascending order (time of
> occurrence).
>
> If I do it this way, how do I actually read the data in and store in
> the file? Toy code, please.
>
>
Hi Bill,
This seems a bit like some heartbeat data that I had to deal with some 
years ago. There were two output streams, one the time of each R wave 
and the other an asynchronous stimulus. In that case, I had to work out 
code to interdigitate the signals and do some processing of the 
resulting data. It sounds like you have two files, each recording times 
of input and output respectively one value to a line. If so, my first 
guess is:

x<-as.vector(read.table("input_times.dat"))
y<-as.vector(read.table("output_times.dat"))
xy<-list(x,y)
# to store this list in a file
# oops, bit too quick on the keyboard
dput(xy,file="xy_23_10_2009.R")

Jim




More information about the R-help mailing list