Displaying 20 results from an estimated 1000 matches similar to: "Questions about readBin function (Was: dec2bin?)"
2005 Oct 01
3
dec2bin?
Hello,
I just want to ask if there is any function that can convert decimal
number to binary vector.
Thanks a lot.
Haiyong
2010 Nov 07
2
stupid R tricks
Hi all,
Just thought I'd post this (maybe) helpful tool I wrote. For people
like me who are bad at keeping a clean environment, it's a time-saver.
#simple command to get only one type of object in current environment
lstype<-function(type='closure'){
inlist<-ls(.GlobalEnv)
if (type=='function') type <-'closure'
2017 Dec 21
7
[PATCH v20 3/7 RESEND] xbitmap: add more operations
This patch adds support to find next 1 or 0 bit in a xbmitmap range and
clear a range of bits.
More possible optimizations to add in the future:
1) xb_set_bit_range: set a range of bits.
2) when searching a bit, if the bit is not found in the slot, move on to
the next slot directly.
3) add tags to help searching.
Signed-off-by: Wei Wang <wei.w.wang at intel.com>
Cc: Matthew Wilcox
2017 Dec 21
7
[PATCH v20 3/7 RESEND] xbitmap: add more operations
This patch adds support to find next 1 or 0 bit in a xbmitmap range and
clear a range of bits.
More possible optimizations to add in the future:
1) xb_set_bit_range: set a range of bits.
2) when searching a bit, if the bit is not found in the slot, move on to
the next slot directly.
3) add tags to help searching.
Signed-off-by: Wei Wang <wei.w.wang at intel.com>
Cc: Matthew Wilcox
2005 Mar 25
2
Casting in R
Hi,
I am looking for functions that would allow me to access raw binary data of
R vectors. One way would be to use:
x = (1:10)*pi
writeBin(x, "temp.bin")
r = readBin("temp.bin", "raw", n=length(x)*8)
Other to write my own C code. Is there any other simpler way?
I this message is a rewording of my yesterday message "Looking for function
for Double to
2005 Aug 22
2
RFC: "loop connections"
I've just implemented a generalization of R's text connections, to
also support reading/writing raw binary data. There is very little
new code to speak of. For input connections, I wrote code to populate
the old text connection buffer from a raw vector, and provided a new
raw_read() method. For output connections, I wrote a raw_write() to
append to a raw vector. On input, the mode
2017 Sep 11
1
[PATCH v15 2/5] lib/xbitmap: add xb_find_next_bit() and xb_zero()
On Mon, Aug 28, 2017 at 06:08:30PM +0800, Wei Wang wrote:
> +/**
> + * xb_zero - zero a range of bits in the xbitmap
> + * @xb: the xbitmap that the bits reside in
> + * @start: the start of the range, inclusive
> + * @end: the end of the range, inclusive
> + */
> +void xb_zero(struct xb *xb, unsigned long start, unsigned long end)
> +{
> + unsigned long i;
> +
2017 Sep 11
1
[PATCH v15 2/5] lib/xbitmap: add xb_find_next_bit() and xb_zero()
On Mon, Aug 28, 2017 at 06:08:30PM +0800, Wei Wang wrote:
> +/**
> + * xb_zero - zero a range of bits in the xbitmap
> + * @xb: the xbitmap that the bits reside in
> + * @start: the start of the range, inclusive
> + * @end: the end of the range, inclusive
> + */
> +void xb_zero(struct xb *xb, unsigned long start, unsigned long end)
> +{
> + unsigned long i;
> +
2002 Nov 29
2
readBin or writeBin adds extra nulls (PR#2333)
Full_Name: Ken Yap
Version: 1.6.1
OS: Linux (SuSE 8.0)
Submission from: (NULL) (129.78.64.5)
I'm trying to copy a file using readBin and writeBin. (The reason is to be able
to pipe PostScript or PDF output to a socket later, this is just an experiment.)
I do:
zz <- file("foo.ps", "rb")
r <- readBin(zz, character(), 1000000)
yy <- file("bar.ps",
2008 Jan 23
0
writeBin doesn't "send" until readBin executed
Hi all -
I'm playing around with an attempt to do some serial communication from
within R to a microcontroller board. I open a connection:
zz = file("/dev/ttyUSB0",open="a+") ## text mode
... when I execute
writeLines("0",con=zz)
I know the board receives the "0" because the board's serial comm LEDs light
up when submit the command at the R
2006 Jun 02
1
Typo fix for readBin.Rd
Hi,
The man page for readBin has a small typo:
--- a/src/library/base/man/readBin.Rd
+++ b/src/library/base/man/readBin.Rd
@@ -58,7 +58,7 @@ writeBin(object, con, size = NA, endian
\code{readBin} and \code{writeBin} read and write C-style
zero-terminated character strings. Input strings are limited to 10000
- characters. \code{\link{readChar}} and \code{\code{writeChar}}
+
2017 Dec 15
2
[PATCH v19 3/7] xbitmap: add more operations
On Fri, Dec 15, 2017 at 10:49:15AM -0800, Matthew Wilcox wrote:
> Here's the API I'm looking at right now. The user need take no lock;
> the locking (spinlock) is handled internally to the implementation.
I looked at the API some more and found some flaws:
- how does xbit_alloc communicate back which bit it allocated?
- What if xbit_find_set() is called on a completely empty
2017 Dec 15
2
[PATCH v19 3/7] xbitmap: add more operations
On Fri, Dec 15, 2017 at 10:49:15AM -0800, Matthew Wilcox wrote:
> Here's the API I'm looking at right now. The user need take no lock;
> the locking (spinlock) is handled internally to the implementation.
I looked at the API some more and found some flaws:
- how does xbit_alloc communicate back which bit it allocated?
- What if xbit_find_set() is called on a completely empty
2007 Dec 31
1
readBin differences on Windows and Linux/mac
I have been trying to use the gunzip function in the R.utils package. It
opens a connection to a gzfile, uses readBin to read from that connection,
and then uses writeBin to write out the raw data to a new file. This works
as expected under linux/mac, but under Windows, I get:
Error in readBin(inn, what= raw(0), size = 1, n=BFR.SIZE) :
negative length vectors are not allowed
A simple
2013 May 08
1
getting corrupted data when using readBin() after seek() on a gzfile connection
Hi,
I'm running into more issues when reading data from a gzfile connection.
If I read the data sequentially with successive calls to readBin(), the
data I get looks ok. But if I call seek() between the successive calls
to readBin(), I get corrupted data.
Here is a (hopefully) reproducible example. See my sessionInfo() at the
end (I'm not on Windows, where, according to the man page,
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
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
2019 Dec 18
0
readBin should check that its endian argument is a legal value
Thank you for reporting this problem, R-devel now has a check in readBin
and writeBin.
I've identified two CRAN packages with an incorrect value for "endian"
and reported to maintainers, unfortunately in their case the intention
was to specify "little".
Best
Tomas
On 11/18/19 11:22 PM, Jennifer Lyon wrote:
> I think it would be helpful if readBin checked that its
2013 Dec 13
0
how to use the readBin ?
how to use the readBin ?
i want to write the extended ascii character `Œ` into a file named c:/testbin,
and read it in the R console ,display it as `Œ` in R console.
now i can write it .
zz <- file("c:/testbin", "wb")
writeBin(charToRaw("\u0152"), zz)
close(zz)
when i open the file with office(encoding=utf-8),i can see `Œ`,whay i can not read it with readBin?
2011 Jun 30
0
socket blocking with readBin
R Gurus / Ninjas / Wizards:
On both R 2.12 (Windows 7) and R 2.13 (OS X 10.5) I have tried the
following:
1. In one instance of R open a socket via:
s1 <- socketConnection(server=TRUE, open="a+b", port=31415,
blocking=FALSE);
2. And in another instance I do the following:
s2 <- socketConnection(open="a+b", port=31415, blocking=FALSE);
And so I