Search code examples
rmatlabfwrite

Is there any R function analogous to MATLAB fwrite(fileID,file,'single') function?


I have a problem saving a double vector (signal) to a binary file with single precision in R. I have used R function writeBin() to save a signal in .sng file, but it is not saving correctly.

writeBin(as.vector(signal),fileID)

Previously, I have used MATLAB and function fwrite(fileID, signal, 'single') and was working perfectly. Now, I am looking to similar R function, analogue to fwrite().

Any help ?

Best, S


Solution

  • The answer of my question is:

    writeBin(as.vector(signal),fileID, size=4)