search for: writebin

Displaying 20 results from an estimated 150 matches for "writebin".

2002 Oct 07
2
Error in writeBin(object, con, size = 2)
...which reads binary data, interpolates sometimes and wrote a new binary file of the same size as the input file. Her is a bit of code: while (length( head <- readBin(si, integer(), 64, size=2))) { data <- readBin(si, integer(), head[5], size=2) ## now write head to new file writeBin(head, so, size=2) ## if head[4] is 9 or 10, interpolate if(head[4] == 9 | head[4] == 10) ## interpolate data data <-int(data) writeBin(data, so, size=2) } si and so are the binary in- and output connections, "int()" interpolates between some data se...
2019 Dec 06
2
long vector support
...l, At first glance, a recent commit to R-devel ( https://github.com/wch/r-source/commit/2c182014ecc8c2407a89092c9162d86046bd18da) appears to be related to long vector support. But as Henrik Bengtsson points out at https://github.com/HenrikBengtsson/Wishlist-for-R/issues/97#issuecomment-562659134, writeBin() still prohibits long vectors. Are there any plans to add long vector support to R 4.0.0? x <- raw(2^31) writeBin(x, con = nullfile()) # Error in writeBin(x, con = nullfile()) : # long vectors not supported yet: connections.c:4430 x <- raw(2^31) con <- rawConnection(raw(0L), "w&qu...
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", "wb") writeBin(r, yy, character(), 1000000) clos...
2003 Apr 25
2
Open an r+b file connection on Windows
...eping the already existing data after that byte. It seems to me that I am unable to open a connection to a binary file in both read and write mode. I can open the "r+b" binary file connection and seek around, but I can't write to the file. And looking at the function definition for writeBin, it seems that writeBin automatically creates a connection of type "wb" not what is specified by the R file object. I am working on Windows Nt 4.0 with R 1.7. Any ideas? Thanks in advance. #Create file x<-1:50 myfile <- file("test","wb") writeBin(as.real(x),m...
2001 Dec 07
2
Memory problem
Dear all, I have written a little R program to convert images. See below. Within the loop over j (the filenames) memory consumption grows constantly. rm( ... ) inside the loop did not help. Memory does not grow if I remove the writeBin statements between the two #-------- marks. But obviously this is not solution I want... Thanks for any advice. Manfred Baumstark P.S. As I'm new to R: what sort of tests can I make to trace the problem? Configuration: R-gui 1.3.1, WinNT 4.0, the same happens in R under IRIX 6.5 ----------...
2011 Feb 04
2
Strange behaviour of read and writeBin
To me it seems like writeBin() writes one char/byte more than expected. > con <- file("testbin", "wb") > writeBin("ttccggaa", con) > close(con) > con <- file("testbin", "rb") > readBin(con, what="character") [1] "ttccggaa" > s...
2010 Jan 07
2
Problem with writeBin and importing into gfortran compiled programs
Hi all, I'm having problems trying to export binary arrays from R and importing them into fortran (linux openSUSE 10.3 (x86_64), gfortran compiler, fortran 90/95 program). Let's say the problem can be expressed as: R part ------------ >whini <- runif(1000) >writeBin(whini,"fwhini.dat") f90 part ------------ PROGRAM foo INTEGER, PARAMETER :: DP = KIND(1.0D0) INTEGER :: status REAL(DP), DIMENSION(10,100) :: whini OPEN(UNIT=5, FILE='fwhini.dat', STATUS='OLD', ACTION='READ', & FORM='UNFORMATTED', IOSTAT=status) R...
2008 Jan 23
0
writeBin doesn't "send" until readBin executed
...z) I know the board receives the "0" because the board's serial comm LEDs light up when submit the command at the R prompt. However, if I want to open the connection to the board in binary mode: zz = file("/dev/ttyUSB0",open="a+b") ## binary mode ...submitting writeBin(as.integer(9), con=zz, size=1) doesn't do anything (no serial comm LEDs active) until AFTER I run a readBin(zz,"integer") I know the data arrives at the board correctly, because if the board receives the right byte over the serial connection, it's been programmed to light a par...
2007 Dec 05
4
Java parser for R data file?
Hi everyone, Has anyone written a parser in Java for either the ASCII or binary format produced by save()? I need to parse a single large 2D array that is structured like this: list( "32609_1" = c(-9549.39231289146, -9574.07159324482, ... ), "32610_2" = c(-6369.12526971635, -6403.99620977124, ... ), "32618_2" = c(-2138.29095689061, -2057.9229403233, ... ),
2013 Aug 14
1
2 questions about signal & broken connection in R
...ch is closed by peer by calling "close(conn)". The 1st write will return. The 2nd write will get an exception. The 3rd write will hang there forever. How can users always get an exception or other error messages when writing to a broken connection, instead of possibly hanging there? > writeBin(as.integer(1), con, endian="big"); > writeBin(as.integer(1), con, endian="big"); Error in writeBin(as.integer(1), con, endian = "big") : ignoring SIGPIPE signal > writeBin(as.integer(1), con, endian="big"); ----- hanging ===================== Rong...
2010 Jul 05
1
export VTK from R : impossible to write data as float
Hello, I've written a short code (below) to write 3D unstructured grid to binary VTK files from R. Problem : I can only write integers with the command : data<-as.numeric(c(3.3)) storage.mode(data)<-'integer' writeBin(data,bfile_celldata,endian="swap") the function storage.mode(data)<-'long' looks fine, but the VTK file is not readable. thanks for any help or comments, #----- R SCRIPT TO WRITE A CUBE IN VTK FORMAT cat('# vtk DataFile Version 3.0\n',file="vtk_header") ca...
2001 Jul 17
1
How to write the bytes 00 01 00 to a file/connection?
Is there any way to write (8-bit) bytes to a file which works on all [R] platforms? I have been looking at 1) writeBin 2) writeChar 3) cat and neither of them manage to write arbitrary sequences of bytes (0-255). For instance, I would like to create a binary file of length three containing the bytes 0, 1 and 0. I [R] I have the following vector of bytes: bfr <- c(0,1,0) 1) For having 'writeBin'...
2024 May 21
1
wrtiteBin in conjunction with seek : the position in the file is not good when writing
Dear RHelp-list, ?I want to write at a specific position in a file without reading all the file because it is very large and I cannot read it in my RAM. But I miss something about the use of the command writeBin in conjunction with seek. In the example bellow the seek commands works well with the readBin command but not with writeBin, the writeBin command write from the beginning of the file and not from the current position and however in the doculentation it is written: ? If the connection is open it...
2010 Jun 16
2
Sending a null byte to a socket
...you put "\000" in a string: > "\000" Error: embedded nul in string: '\0' I thought perhaps that write.socket would automatically send a null byte, but it doesn't appear to. I'm getting similar results with socketConnection() and writeLines(). I thought that writeBin() might be the solution but it gives me: Error in writeBin(n, con) : can only write to a binary connection I'm not clear how to make my socket a binary connection. I am only going to be writing strings, with the exception of these null bytes. Can anyone suggest a method for doing this? Thank...
2009 Apr 30
2
NA_real_ <op> NaN -> NA or NaN, should we care?
...ation (just -g) then both of those return NA. On Windows, using a precompiled R 2.8.1 from CRAN I get NA for both answers. On Linux, after compiling src/main/arithmetic.c with -g -O2 the bit patterns for NA_real_ and as.numeric(NA) are different: > my_numeric_NA <- as.numeric(NA) > writeBin(my_numeric_NA, ptmp<-pipe("od -x", open="wb"));close(ptmp) 0000000 07a2 0000 0000 7ff8 0000010 > writeBin(NA_real_, ptmp<-pipe("od -x", open="wb"));close(ptmp) 0000000 07a2 0000 0000 7ff0 0000010 On Linux, after compiling with -g the...
2019 Dec 07
0
long vector support
...proper R bug report, where the change was very simple indeed , PR#17665, i.e. https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17665 > But as > Henrik Bengtsson points out at > https://github.com/HenrikBengtsson/Wishlist-for-R/issues/97#issuecomment-562659134, > writeBin() still prohibits long vectors. Are there any > plans to add long vector support to R 4.0.0? well.. there *is* a lot of long vector support in R 3.x.y already. Where there are gaps, 1) we have to be told about (i.e. it should be a case where people at least have stumbled about it) -- pr...
2020 May 06
3
defining r audio connections
...a package? I can see from the R source that, for example, `do_gzfile` is defined in `connections.c` and referenced in `names.c`. However, I thought I should ask here first in case there is a better place to start, than trying to copy this code. I only want an object that I can use `readBin` and `writeBin` on, to read and write audio data using e.g. `snd_pcm_writei` which is part of the `alsa-lib` package. Thank you very much, Frederick
2005 Oct 12
1
Questions about readBin function (Was: dec2bin?)
Hi, The latest version of R had some changes to functions "readbin() and writeBin() [which] now support raw vectors as well as filenames and connections.". As a result I am working on retiring "raw2bin" and "bin2raw" functions from "caTools" package which do exactly the same. Thanks to Prof. Ripley for bringing this change to my attention. Whi...
2012 May 02
6
Quickest way to make a large "empty" file on disk?
R-helpers: What would be the absolute fastest way to make a large "empty" file (e.g. filled with all zeroes) on disk, given a byte size and a given number number of empty values. I know I can use writeBin, but the "object" in this case may be far too large to store in main memory. I'm asking because I'm going to use this file in conjunction with mmap to do parallel writes to this file. Say, I want to create a blank file of 10,000 floating point numbers. Thanks! --j -- Jonatha...
2008 Oct 28
2
writting null (\000 or ^@) to an external text file without the new warning
I have some functions that write an external text file for postprocessing by another program. Some instructions to the other program need to be indicated by null values (\000 or ^@). The function currently uses code like: writeChar(rawToChar(as.raw(0)), con) where con is a connection to the file. Previous to version 2.8.0 this worked fine. With 2.8.0 it still works, but I get a warning