Displaying 20 results from an estimated 6000 matches similar to: "unsigned 4 byte number"
2006 Sep 27
2
Single Precision (4 byte) floats with readBin
I would like to use readBin to read a binary data
file. Most of the data is 4-byte floating point but,
for some reason, only double precision appears to be
offered. I tried
fVariable=readBin(iFile,what=single());
and got 35.87879 which looks believable except that
the correct value is 3.030303. I then tried
fVariable=readBin(iFile,what=single(),4);
and got
[1] 3.831111e+10 6.657199e+10
2002 Mar 05
3
reading 2-byte integers using readBin and connections
Hi folks:
This may be a stupid question, but I cannot seem to find a way to tell
readBin that I want to read 2-byte integers from the connection. The input
file is 150,720 bytes long containing 75,360 short (2-byte) integers. But
specifying "integer" or "int" for what in readBin only returns me a vector
of length 37680, leading me to believe that sizeof(integer) or
2008 May 29
2
Reading an "unsigned long long" using R readBin()
Sorry for the simple question, but I am trying to read an "unsigned
long long" using the R readBin() function. Can someone point me in
the right direction, or am I better off using C for such things? The
file that I am reading will have been produced on the same machine
that is doing the reading.
Thanks,
Sean
2011 Mar 29
2
Reading 64-bit integers
Dear all,
I see from some previous threads that support for 64-bit integers in R
may be an aim for future versions, but in the meantime I'm wondering
whether it is possible to read in integers of greater than 32 bits at
all. Judging from ?readBin, it should be possible to read 8-byte
integers to some degree, but it is clearly limited in practice by R's
internally 32-bit integer type:
2009 Jun 24
1
Reading 4-byte float into R from binary file
A simple question, I hope.... I have a binary file format that I want to
slurp into R using readBin. There are a couple of fields in the file that
are 4-byte floats. Since R has no "float" data type (4-byte), I am
wondering how to go about this task. I could simply do all the work in C,
but the format is pretty simple, so I wanted to do it using just R. I did
see as.single, but it
2011 Sep 01
4
readBin fails to read large files
Posting for a friend
Begin forwarded message:
From: "Geier, Florian" <florian.geier08@imperial.ac.uk<mailto:florian.geier08@imperial.ac.uk>>
Subject: Fwd: readBin fails to read large files
Date: September 1, 2011 4:10:53 PM GMT+01:00
To:
Begin forwarded message:
Date: 1 September 2011 16:01:45 GMT+01:00
Subject: readBin fails to read large files
Dear all,
I am trying
2012 May 03
2
Help with readBin
I'm trying to read a binary file created by a fortran code using readBin
and readChar. Everything reads fine (integers and strings) except for
double precision numbers, they are read as huge or very small number
(1E-250,...). I tried various endianness, swap, But nothing has worked so
far.
I also tried on R 64 bit for linux and windows (R 2.14) and R 2.11 on
windows XP 32 bit.
Any help would
2004 Mar 10
1
reading binary file with different modes
I have a binary file representing a matrix with columns of different
variable type/mode (i.e. the file was saved from C using double and int
variables)
I want to import it into R, I've been reading the R Import/Export and I
am able to use readBin for a file that contains only one variable type
(either all doubles or all ints) but I can not find the way to use it
when you have a file with
2009 Jan 09
1
Saving plots as byte streams
Is it possible to save plots as byte streams? For example, if I want the
bytes for a PNG plot, I could use
#Write the plot to a PNG file
png("test.png")
plot(1:10)
dev.off()
#Read the bytes back in from the file
plotbytes <- readBin("test.png", "raw", n=2000)
Ideally, I'd like to avoid having to bother writing to the file in the
first place, and simply
2010 Jun 16
1
Decoding raw vectors every other byte
I have to decode raw vectors read from a connection like this:
+++++++++++++++++++
fl<-file.choose()
fb<-file.info(fl)$size
fc<-file(fl)
open(fc,open='rb')
seek(fc,where=offset)
dat<-readBin(fc,'raw',n=(fb-offset),size=1,signed=FALSE)
close(fc)
++++++++++++++++++
The decoding performs a combination of a simple bitwise operator and a
simple arithmatic operator on
2012 Jun 19
1
seek(), skip by bits (not by bytes) in binary file
Hello,
Has a function been built that will skip to a certain bit in a binary file?
As of 2009 the answer was 'no':
http://r.789695.n4.nabble.com/read-binary-file-seek-td900847.html
https://stat.ethz.ch/pipermail/r-help/2009-May/199819.html
If you feel I don't need to (like in the links above), please provide some
help. (Note this is my first time working with binary files.)
I'm
2009 Dec 17
1
Problem reading binaries created with fortran (More infos)
The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)
here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4 34.5 ......
I tried to read the first line with readBin (results are copied below):
2006 Oct 21
2
Possible bugs in 'seek' and 'readBin'
I found that
seek(..., origin = 'current', ...)
and
readBin(..., what = 'integer', ...)
or 'int'
do not work correctly.
Did anyone have the same experience?
2006 Nov 09
2
Single precision data behaviour with readBin()
Hi all,
I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake
10.2 Linux. I was given a binary data file containing single precision
numbers that I would like to read into R. In a previous posting,
someone suggested reading in such data as double(), which is what I've
tried:
> zz <- file(file, "rb")
> h1 <- readBin(con = zz, what = double(), n = 1, size
2012 May 24
6
R does not recognise columns and rows as they are supposed to be
Dear All,
The code given bellow is to extract values of one region and write that to
a text file(there are 365 binary files in the directory).
The problem which I am facing is that all my files are binary with size of
360 rows and 720 columns.
I specified that in this line: file2<-matrix(data=file,ncol=720,nrow=360)
but I got an error : Error in mean(file2[X, Y], na.rm = TRUE) : subscript
2009 May 18
2
readBin on binary non-blocking connections (Windows & Unix differences/bugs)
R-devel:
I am encountering a consistency issue using socketConnection and
readBin with *non-blocking* connections on Unix and Windows XP (no
Vista to test).
I am a bit confused by the behavior of *non-blocking* connections
under Windows specifically. When calling readBin on a non-blocking
connection when there is no data to read on the socket, the connection
under Unix will return a vector of
2006 Jun 28
2
read file with readBin (the file was saved with a C-routine)
Hello!
I have problems with using of "readBin" to read files, which was written in C with "fwrite". In the C-File there is the following Code:
fwrite(MyitINI,sizeof(itINItype),1,outfile);
where MyitINI is a structure of the following form
typedef struct{
int KernelFileSave; /* Determined, if Systemmatrix saved or not.*/
char KernelFileName[200]; /* A-Matrix name
2004 Jun 01
2
Importing binary data
Hi everybody!
I've a large dataset, about 2 Mio entries of the format which I would like
to import into a frame:
<integer><integer><float><string><float><string><string>
Because to the huge data amount I've choosen a binary format instead
of a text format when exporting from Matlab.
My import function is attached below. It works fine for only
2003 Feb 13
5
ESRI shape file import and time-space models
Dear R user,
I am running R under Windows 2000.
I am looking for a routine for importing
- shape files (ESRI) into R
- dbase files (FOXPRO) into R
and I am looking for time-space models for description and prediction of
Bernoulli-, Binomial- and Poissonvaraibles.
Thank's a lot for a reply.
Sincerely yours,
Ekkehardt Altpeter
Swiss Federal Office of Public
2019 Nov 18
2
readBin should check that its endian argument is a legal value
I think it would be helpful if readBin checked that its endian argument is
a legal value.
Why? I was reviewing some of our code and noticed that the author had
readBin(..., endian="network") and never having heard of "network", I
looked at the man page for readBin, and it hadn't heard of "network"
either. Not good.
I then looked at the R code for readBin, which