[R] data file with columns of unequal length

William Simpson william.a.simpson at gmail.com
Fri Oct 23 13:23:09 CEST 2009

OK thanks, I look at sleep and get it


On Fri, Oct 23, 2009 at 12:21 PM, Peter Dalgaard
<P.Dalgaard at biostat.ku.dk> wrote:
> William Simpson wrote:
>>> As I understand it, they don't come in pairs anyway.
>> Correct.
>>> For the same reason
>>> a data frame is just the wrong kind of data structure. If you don't want
>>> separate data files, you can use one file with two columns where the
>>> second column is (say) 1 for the x and 2 for the y.
>> Could you explain this further? I don't really get it.
>> My xs and ys have different lengths. How would I read them in?
> Same format as when you have data from two different groups. Don't
> really know how to make it clearer than that. Like the "sleep" dataset
> (OK, so they are actually paired...).
>> Ideally I would just read in the x column and y columns separately
>> x<-read.file("file.dat", column1)
>> y<-read.file("file.dat", column2)
>> But I know of no way to do that...
>> [Oh, by the way, I never mentioned this, the x and ys are event times
>> and are in ascending order (by time of occurrence).]
>>> (There are other options, like concatenating the x and the y with some
>>> sort of separator inbetween, but it easily gets painful to read them
>>> back in.)
> --
>   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907

More information about the R-help mailing list