From: jim holtman <jholtman_at_gmail.com>

Date: Wed 08 Feb 2006 - 11:45:11 EST

Date: Wed 08 Feb 2006 - 11:45:11 EST

Read it into a vector and then convert into a matrix; convert to a data frame:

df <- readBin("d:/sim.data", what='double', n=10000, size=4) # make n
greater than file size

dim(df) <- c(2, length(df) / 2)

df <- t(df)

colnames(df) <- c('age', 'weight')

df <- as.data.frame(df)

On 2/7/06, www.brook@gmail <www.brook@gmail.com> wrote:

*>
*

> Each data (edge,weight) is numerical data with type double (4 bytes)

*>
**> df<-file("d:/sim.data","rb")
**> age[1]<-readBin(df,double())
**> weigt[1]<-readBin(df,double())
**> ...
**> age[10]<-readBin(df,double())
**> weigt[10]<-readBin(df,double())
**>
**> it is not asc file.
**>
**>
**>
**> ======= 2006-02-07 13:03:17 =======
**>
**> >www.brook@gmail wrote:
**> >> I have a binary file with data sequence in the order
**> >
**> > What do you mean by 'binary file'?
**> >
**> >> [age,weight][age,weight] ....
**> >
**> > How are age and weight encoded in this 'binary file'?
**> >
**> >> I know the length of the data and I want to load it into a
**> >> data.frame. of course a way to do this is to read age and weight
**> >> seperately and then use cbin(age,weight) to combine them into a
**> >> dataframe, but is there a better solution?
**> >>
**> >
**> > Is it really an ASCII file? With age and weight separated by commas,
**> >and then age-weight pairs separated by spaces? Are there really square
**> >bracket pairs in there too?
**> >
**> > Or is it really a binary file, a series of 4 or 8-byte binary
**> >representations of age and weight?
**> >
**> > Barry
**>
**> = = = = = = = = = = = = = = = = = = = =
**>
**>
**>
**>
**>
**> www.brook
**> www.brook@gmail.com
**> 2006-02-07
**>
**>
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide!
**> http://www.R-project.org/posting-guide.html
**>
**>
*

-- Jim Holtman Cincinnati, OH +1 513 247 0281 What the problem you are trying to solve? [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlReceived on Wed Feb 08 11:58:47 2006

*
This archive was generated by hypermail 2.1.8
: Fri 10 Feb 2006 - 19:37:01 EST
*