[R] readBin into a data frame

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Aug 2 11:15:31 CEST 2013


I find the hexView package quite helpful for this.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:
>
>
>On 01.08.2013 10:36, Zhang Weiwu wrote:
>> Hello. readBin is designed to read a batch of data with the same
>spec,
>> e.g. read 10000 floats into a vector. In practise I read into data
>> frame, not vector.  For each data frame, I need to read a integer and
>a
>> float.
>>
>> for (i in 1:1000) {
>>      dataframe$int[i]   <- readBin(con, integer(), size=2)
>>      dataframe$float[i] <- readBin(con, numeric(), size=4)
>> }
>
>
>Ideally one would read bunches of identical types within R. This seems 
>not to be possible here, hence I'd suggest to read it via some C code.
>
>Best,
>Uwe Ligges
>
>
>
>>
>> And I need to read 100 such data files, ending up with a for loop in
>a
>> for loop. Something feels wrong here, as it is being said if you use
>> double-FOR you are not speaking R.
>>
>> What is the R way of doing this? I can think of writing the content
>of
>> the loop into a function, and vectorize it -- But, the result would
>be a
>> list of list, not exactly data-frame, and the list grows
>incrementally,
>> which is inefficient, since I know the size of my data frame at the
>> outset. I am a new learner, not speaking half of R vocabulary, kindly
>> provide some hint please:)
>>
>> Best.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list