similar to: Clarification for readChar man page

Displaying 20 results from an estimated 4000 matches similar to: "Clarification for readChar man page"

2002 Apr 26
4
Memory "leak" in readChar (PR#1483)
Full_Name: Hugh C. Pumphrey Version: 1.4.1 OS: Linux (Debian Woody) Submission from: (NULL) (129.215.133.170) The function readChar() appears to have some type of problem with memory allocation. I don't know if "memory leak" is the correct term but if one uses readChar() many times, the R binary grows in size until it eats all your memory and swap space. The code enclosed below
2003 Nov 14
2
writeChar potential buffer overrun (PR#5090)
Trying to copy the (binary) header of a input file directly to an output file, I've had repeatable seg faults. The call: writeChar(hdr, outfh, nchars=6144) when hdr just contains one empty string seems to be the culprit. The stack traces weren't all that illuminating, with sig 11 in memory-related functions following this. But in src/main/connections.c it looks like do_writechar
2024 Jan 26
1
readChar() could read the whole file by default?
I am curious why readLines() has a default (n=-1L) to read the full file while readChar() has no default for nchars= (i.e., readChar(file) is an error). Is there a technical reason for this? I often[1] see code like paste(readLines(f), collapse="\n") which would be better served by readChar(), especially given issues with the global string cache I've come across[2]. But lacking the
2024 Jan 26
1
[External] readChar() could read the whole file by default?
On Fri, 26 Jan 2024, Michael Chirico wrote: > I am curious why readLines() has a default (n=-1L) to read the full > file while readChar() has no default for nchars= (i.e., readChar(file) > is an error). Is there a technical reason for this? > > I often[1] see code like paste(readLines(f), collapse="\n") which > would be better served by readChar(), especially given
2006 Mar 30
1
Writing character vectors with embedded nulls to a connection
Is this possible? I've tried both writeChar() and writeBin() to no avail. My goal is to serialize(ascii=FALSE) an object to a connection but determine the size of the serialized object before hand: sobject <- serialize(object,NULL,ascii=FALSE) len <- nchar(sobject) # # run some code here to notify listener on other end of connection # how many bytes I'm getting ready to send #
2024 Jan 29
1
[External] readChar() could read the whole file by default?
My opinion is that the proposed feature would be greatly appreciated by users. I had always wondered if I was the only one doing paste(readLines(f), collapse="\n") all the time. It would be great to have the proposed, more straightforward way to read the whole file as a string: readChar("my_file.txt", -1) or even better readChar("my_file.txt") Thanks for your detailed
2003 Nov 06
2
Summary: How to represent pure linefeeds chr(10) under R for Windows
Thanks to all who have responded. My concern was to be able to write a csv file that can have line feeds in string columns chr(10). Why? Excel allows line feeds chr(10) within cells and line breaks chr(13)+chr(10) at line ending, but the windows version of R automatically replaces \n by \r\n in writing and \r\n by \n in reading (text mode). The clues for a solution came from Brian Ripley and
2006 Aug 29
1
writeChar
I have recently been using writeChar and writeBin to write binary files. These functions makes it very easy to write OS-independent files, which I am very happy with. I have however found a few issues, best illustrated by a short example > con <- file("test", open = "wb") > writeChar(as.character(c("ab", "ab")), nchars = c(3), con = con,
2018 May 29
1
Buffering in R 3.5 connections causes incorrect data in readChar
Tomas, Thank you for the explanation. I see in the documentation: "These functions are intended to be used with binary-mode connections." So I see how using it on a text connection is undefined, and not a bug. An error or warning when attempting to use a it on a text connection would be helpful considering how the behavior has changed in R-3.5. On Tue, May 29, 2018 at 3:09 AM, Tomas
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:
2010 Sep 22
1
help with sockets in R
Hi R gurus, I'm trying to use a ReSTful web service from within R. Specifically, I need to make HTTP PUT requests. I'm able to make the request and that goes well enough, but I'm having trouble properly consuming the HTTP response. The problem comes in when I'm trying to parse out the response body. I get the length of the response body from the Content-Length header. I then try
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}} +
2024 Feb 17
1
certain pipe() use cases not working in r-devel
I've now tested with: > R.version.string [1] "R Under development (unstable) (2024-02-16 r85931)" and all of the previously mentioned examples now work as expected on macOS. Thanks for the quick fix, Jenny On Thu, Feb 15, 2024 at 8:02?AM Tomas Kalibera <tomas.kalibera at gmail.com> wrote: > > On 2/14/24 23:43, Jennifer Bryan wrote: > > Hello, > > >
2024 Feb 14
2
certain pipe() use cases not working in r-devel
Hello, I've noticed a specific type of pipe() usage that works in released R, but not in r-devel. In 4.3.2 on macOS, I can write to a connection returned by pipe(), i.e. "hello, world" prints here: > R.version.string [1] "R version 4.3.2 (2023-10-31)" > con <- pipe("cat") > writeLines("hello, world", con) hello, world But in r-devel on
2010 May 05
1
handling nulls while reading mainframe file
Hi, I am trying to read in records from an old main frame file. Each record is 640 bytes. I had some success using the following statement: iconv(readChar(con, nchars=640, useBytes = TRUE),from="IBM037",to="",sub="#") What I have found, however, is that ocassionally a record will contain a Null halfway through, which causes readChar() not to read the rest of the
2018 May 26
2
Buffering in R 3.5 connections causes incorrect data in readChar
I noticed an issue where readChar does not return the correct value after a call to readline. It appears that readChar is not aware of the buffering, so it reads from the end of the buffer, rather than the current position in the file. This is a significant change of behavior from R-3.4.4. Below is a test case that I used to home in on the problem. --- p<-"test2.txt"
2006 Apr 27
1
Error in readChar(): invalid UTF-8 input
I have R code to read a binary header file, consisting of several readBin() and readChar() statements. I am currently using version R-2.2.1 (on x86_64, RH EL4) and have received the following error Error in readChar(fid, n = 1) : invalid UTF-8 input in readChar() This is strange because (a) I was able to read in this file successfully in previous versions of R (circa 2005) and (b) it
2006 Jul 16
1
Generating valid R code using R
Hi, I'm trying to generate valid R code using R. Parts of the task is to read a sequence of characters from file and escape them such that they can be put in quotation marks to form a valid R code string. Example: Let the input file be (four rows containing ASCII 0-255 characters): abcdef<tab>ghijk\nlmno second row\t\a\\ fourth and so on... <EOF> Now, find escapeString() such
2006 Jul 16
1
Generating valid R code using R
Hi, I'm trying to generate valid R code using R. Parts of the task is to read a sequence of characters from file and escape them such that they can be put in quotation marks to form a valid R code string. Example: Let the input file be (four rows containing ASCII 0-255 characters): abcdef<tab>ghijk\nlmno second row\t\a\\ fourth and so on... <EOF> Now, find escapeString() such
2007 Dec 09
1
Problems working with large matrix (using package R.huge)
Hi all, Since I was having several problems trying to work with a large matrix I started to use the package R.huge but I'm having the following problem > x<-FileByteMatrix("covtype.data",nrow=581012,ncol=55) Error: cannot allocate vector of size 770.8 Mb In addition: Warning messages: 1: Reached total allocation of 447Mb: see help(memory.size) in: readChar(con = con, nchar =