[R] help on readBin in R

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Apr 17 05:13:49 CEST 2017


That may or may not work, since text file newlines get altered in them. May have more luck with a "png" extension? 
-- 
Sent from my phone. Please excuse my brevity.

On April 16, 2017 7:33:06 PM PDT, jim holtman <jholtman at gmail.com> wrote:
>If the file is not too large, just change the extension to '.txt' and
>attach it.  Also include the code that you are using to read it in and
>a definition of the what the data is; e.g., first two byte are
>temperature, next four bytes are a station ID, ....
>
>Here is an example of reading in a binary file and I know that the
>'raw' output matches the bytes that are in the file:
>
>> infile <- file("test.txt", 'rb')
>>
>> input <- readBin(infile, raw(), 100)
>>
>> input
>  [1] 50 4b 03 04 14 00 04 00 08 00 47 95 90 4a 9f 00 7a a0 99 01 00
>00 7a 08 00 00 13 00 75 00 5b 43 6f
> [34] 6e 74 65 6e 74 5f 54 79 70 65 73 5d 2e 78 6d 6c 53 44 60 00 a4
>00 00 00 00 08 00 32 fa a9 3f 63 64
> [67] 60 69 11 61 60 60 30 00 62 10 f0 01 62 46 56 30 93 55 14 48 55
>e8 cd 15 fe e5 cf a3 df 6c ab ed 66
>[100] b1
>>
>
>here is the dump:
>
>$ od -a -t x --endian=big test.txt
>0000000   P   K etx eot dc4 nul eot nul  bs nul   G nak dle   J  us nul
>               504b0304        14000400        08004795        904a9f00
>0000020   z  sp  em soh nul nul   z  bs nul nul dc3 nul   u nul   [   C
>               7aa09901        00007a08        00001300        75005b43
>0000040   o   n   t   e   n   t   _   T   y   p   e   s   ]   .   x   m
>               6f6e7465        6e745f54        79706573        5d2e786d
>
>Jim Holtman
>Data Munger Guru
>
>What is the problem that you are trying to solve?
>Tell me what you want to do, not how you want to do it.
>
>
>On Sun, Apr 16, 2017 at 9:21 PM, Jeff Newmiller
><jdnewmil at dcn.davis.ca.us> wrote:
>> The mailing list has tight restrictions on attachments, so your
>attachment was not let through. Read the Posting Guide, and note that
>sometimes success requires some extended understanding of how your mail
>software works, and we probably don't know the details either. You
>might have success changing the file extension or sending a link to the
>file on a file storage website like Google Drive or Dropbox.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On April 16, 2017 3:49:07 PM PDT, "M.M saifuddin"
><mmsaifuddin09 at gmail.com> wrote:
>>>I need to view the attached  binary file. but can not read it,
>instead
>>>am
>>>getting very weird( i think garbage) numbers.
>>>
>>>The values are Temperature data so it should be somewhat in between
>250
>>>to
>>>500.
>>>
>>>Can any altruist view it and give me the R code to view it.
>>>
>>>I am attaching the file. Please help me if you can.
>>>
>>>TIA
>>>______________________________________________
>>>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>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 -- To UNSUBSCRIBE and more, see
>> 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