similar to: file connection, while, readLines and browser

Displaying 20 results from an estimated 10000 matches similar to: "file connection, while, readLines and browser"

2001 Oct 02
1
problem with while loop with next (was RE: file connection, w hile, readLines and browser)
Dear R-help, I think I have kinda isolated the problem I had to the following: i <- 0 while( {i <- i + 1} < 5) { if(i < 3) next print(i) } This seems to go into an infinite loop. After I break the execution, i has the value 1. At the R prompt, if I start from i <- 0 and keep typing {i <- i + 1} < 5, it eventually evaluate to TRUE. So why does the while loop not work?
2001 Oct 02
0
An example (was RE: file connection, while, readLines and bro wser)
Prof. Gentleman (and R-help), Here's an example of what didn't work. I still don't understand why. Function: trycon <- function(file, n) { f.con <- file(file, open="rt") on.exit(close(f.con)) i <- 0 while( length(readln <- readLines(f.con, 1)) > 0 ) { x <- unlist(strsplit(readln, " ")) if(length(x) <= 6 && x[3] ==
2001 Oct 02
1
RE: problem with while loop with next
Prof. Tierney, Thanks very much for the info. Why does the loop work if I move the assignment out of the condition? E.g., the following works: i <- 0 while(i < 5) { i <- i + 1 if(i < 3) next print(i) } Regards, Andy > -----Original Message----- > From: Luke Tierney [mailto:luke at nokomis.stat.umn.edu] > Sent: Tuesday, October 02, 2001 3:36 PM > To: Liaw, Andy
2006 Apr 20
1
Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...) [Broadcast]
I quoted the relevant part of the documentation for you. Have you actually try to read what it says? Sure, you don't get any error, but have you checked whether any bootstrapping was actually done? Most of those functions are generics, thus having the "..." argument that can take anything. Doesn't mean they will be used. See if the following helps: > x <- 1:10 >
2009 Oct 13
1
Iterating over file lines
I am attempting to iterate over a file, processing it line by line. In my function below, I am only getting the first item over and over and over again from my test file rather than subsequent lines. How can I modify this to read lines sequentially? == iteratefile <- function(file) { f.con <- file(file) on.exit(close(f.con)) while( length(readln <- readLines(f.con, 1)) > 0 ) {
2006 Apr 20
1
Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...)
> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Michael > Sent: Thursday, April 20, 2006 3:50 AM > To: R-help at stat.math.ethz.ch > Subject: [R] Bootstrap error message: Error in > statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast] > > > Dear colleagues, >
2006 Aug 16
1
Problem with the special argument '...' within a function
I'm not sure if this is what you want, but simply add ... to the list of arguments for fun1 and fun2 would eliminate the error. Andy From: Hans-Joerg Bibiko > > Dear all, > > I wrote some functions using the special argument '...'. OK, it works. > > But if I call such a function which also called such a > function, then I get an error message about unused
2003 Feb 11
2
configure can't get readline to work
Dear R-help, I'm running into some strange problem compiling R 1.6.2 on Mandrake Linux 9.0. When I do ./configure --enable-R-shlib I get the following in config.log: =========================== configure:11366: checking for rl_callback_read_char in -lreadline configure:11397: gcc -o conftest -g -O2 -L/usr/local/lib conftest.c -lreadline -ldl -lm >&5
2018 May 10
0
readLines() behaves differently for gzfile connection
Would it be possible to get that file or a representative subset of it somewhere so that I can reproduce this? Thanks, Michael On Thu, May 10, 2018 at 3:31 PM, Ben Heavner <bheavner at gmail.com> wrote: > When I read a .gz file with readLines() in 3.4.3, it returns text (and a > warning). In 3.5.0, it gives a warning, but no text. Is this expected > behavior or a bug? > >
2017 Dec 14
0
cannot destroy connection (?) created by readLines in a tryCatch
On Thu, Dec 14, 2017 at 12:17 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote: > On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker <gmbecker at ucdavis.edu> > wrote: > > Gabor, > > > > You can grab the connection and destroy it via getConnection and then a > > standard close call. > > Yeah, that's often a possible workaround, but since this
2017 Dec 14
0
cannot destroy connection (?) created by readLines in a tryCatch
Gabor, You can grab the connection and destroy it via getConnection and then a standard close call. (it actually lists that it is "closed" already, but still in the set of existing connections. I can't speak to that difference). > tryCatch( + readLines(tempfile(), warn = FALSE)[1], + error = function(e) NA, + warning = function(w) NA + ) [1] NA >
2017 Dec 14
0
cannot destroy connection (?) created by readLines in a tryCatch
This has nothing to do with on.exit. It is an iteraction between where the warning is signaled in 'file' and your _exiting_ warning handler. This combination has the same issue, tryCatch(file(tempfile(), "r"), warning = identity) showConnections(all = TRUE) as does options(warn=2) file(tempfile(), "r") showConnections(all = TRUE) I haven't looked at the
2009 Sep 23
0
warnings handled oddly in functions with browser calls (PR#13967)
Full_Name: Rich Calaway Version: 2.9.2 OS: Windows Vista Submission from: (NULL) (65.47.30.18) Consider the following function: myfun <- function(){ print(log(-1)) browser() print("Good-bye!") } In the default case, with options(warn=0), if I call this function and type nothing but standard browser commands (c, n, where, Q) at the browser prompt, the warning produced by log(-1)
2018 May 10
1
readLines() behaves differently for gzfile connection
You bet - it's available on github at https://github.com/UW-GAC/wgsaparsr/blob/master/tests/testthat/1k_annotation.gz -Ben On Thu, May 10, 2018 at 4:17 PM, Michael Lawrence <lawrence.michael at gene.com > wrote: > Would it be possible to get that file or a representative subset of it > somewhere so that I can reproduce this? > > Thanks, > Michael > > On Thu, May
2001 Oct 03
8
Several R vs S-Plus issues
Hi, all, I've been converting code from S-Plus ("S" for short) to R for a few weeks. Here are some differences I've found, aside from the big well-known ones (scoping, models, data storage) and the contents of Kurt Hornik's FAQ section 3.3.3. Let me start with the ones that seem like serious bugs or deficiencies: 1) LETTERS[c(NA,2)] in S is
2001 Oct 03
8
Several R vs S-Plus issues
Hi, all, I've been converting code from S-Plus ("S" for short) to R for a few weeks. Here are some differences I've found, aside from the big well-known ones (scoping, models, data storage) and the contents of Kurt Hornik's FAQ section 3.3.3. Let me start with the ones that seem like serious bugs or deficiencies: 1) LETTERS[c(NA,2)] in S is
2006 Apr 24
1
Handling large dataset & dataframe [Broadcast]
Here's a skeletal example. Embellish as needed: p <- 5 n <- 300 set.seed(1) dat <- cbind(rnorm(n), matrix(runif(n * p), n, p)) write.table(dat, file="c:/temp/big.txt", row=FALSE, col=FALSE) xtx <- matrix(0, p + 1, p + 1) xty <- numeric(p + 1) f <- file("c:/temp/big.txt", open="r") for (i in 1:3) { x <- matrix(scan(f, nlines=100), 100,
2018 May 10
2
readLines() behaves differently for gzfile connection
When I read a .gz file with readLines() in 3.4.3, it returns text (and a warning). In 3.5.0, it gives a warning, but no text. Is this expected behavior or a bug? 3.4.3: > source_file = "1k_annotation.gz" > readfile_con <- gzfile(source_file, "r") > readLines(readfile_con, n = 5) [1] "#chr\tpos\tref\talt\t <truncated output here> Warning message: In
2017 Dec 14
2
cannot destroy connection (?) created by readLines in a tryCatch
Consider this code. This is R 3.4.2, but based on a quick look at the NEWS, this has not been fixed. tryCatch( readLines(tempfile(), warn = FALSE)[1], error = function(e) NA, warning = function(w) NA ) rm(list=ls(all.names = TRUE)) gc() showConnections(all = TRUE) If you run it, you'll get a connection you cannot close(), i.e. the last showConnections() call prints: ?
2017 Dec 15
1
cannot destroy connection (?) created by readLines in a tryCatch
Thanks for tracking this down. Yeah, I should use suppressWarnings(), you are right. Although, readLines() might throw another warning, e.g. for incomplete last lines, and you don't necessarily want to suppress that. TBH I am not sure why that warning is given: ? con <- file(tempfile()) ? open(con) Error in open.connection(con) : cannot open the connection In addition: Warning message: In