How can I read float data from a binary file using R -


I know that there is no float in R. So how can I read float data from a binary file? The structure of the data in C is as follows:

  typewf strait {int date; Int'l Open; Int high; Int less; Int close; Float amount; Int Wall; Int reservation; } StockData; To.read = file (filename, "rb"); Line1 = readBin (to.read, "int", 8);  

The amount is not worth the value. How can I get the right value to float?

Your C structure is composed of 5 integer values ​​A float and then 2 integers again, then you < Code> readBin can call three times:

  line1 & lt; -c (readBin (to.read, "int", 5), readBin (to.read, "double", 1, size = 4), readBin (to.read, "int", 2))  

You handle float value by size with a float size of 4 bytes (a Double instead of 8) size logic to 4 ).


Comments