[R] Custom error handling without stopping execution?

2015-04-14 Thread Thomas Nyberg
Hello I've been trying to produce a general error logging/handling framework that I can live with. I'll post the code first: example.R --- good_main <- function() { for (i in 1:2) { bad_function() } } bad_main <- function() { for (i in 1:2) { tr

Re: [R] write.csv to text string?

2015-03-12 Thread Thomas Nyberg
again everyone! Cheers, Thomas On 03/12/2015 02:12 PM, John McKown wrote: > On Thu, Mar 12, 2015 at 12:15 PM, Thomas Nyberg wrote: >> Hello, >> >> I've found the following useful functionality: >> >>> s <- 'cola,colb\n1,2\n2,3\n' >>> r

Re: [R] write.csv to text string?

2015-03-12 Thread Thomas Nyberg
s } read.csv.str <- function(s) { read.csv(text=s) } readfile <- function(filepath) { text <- readChar(filepath, file.info(filepath)$size) text } --- Thanks for the help everyone. Cheers, Thomas On 03/12/2015 02:12 PM, John McKown wrote: > On Thu, Mar 12, 2015 at 12:15 PM

[R] write.csv to text string?

2015-03-12 Thread Thomas Nyberg
d be the easiest way to go about such a thing? Right now I can only think of using a file as an intermediary, but that seems a bit silly. Thanks for any help. Cheers, Thomas Nyberg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https

Re: [R] How to speed up list access in R?

2014-10-30 Thread Thomas Nyberg
23456789 10 4976 4968 4912 5111 5009 5074 4987 4950 5166 4847 Notice the following features of my code: * no object initialization * no loops More comments inline. On Thu, Oct 30, 2014 at 8:17 AM, Thomas Nyberg wrote: Hello, I want to do the following: Given a

Re: [R] How to speed up list access in R?

2014-10-30 Thread Thomas Nyberg
om On Thu, Oct 30, 2014 at 8:17 AM, Thomas Nyberg wrote: Hello, I want to do the following: Given a set of (number, value) pairs, I want to create a list l so that l[[toString(number)]] returns the vector of values associated to that number. It is hundreds of times slower than the equivalent that I w

[R] How to speed up list access in R?

2014-10-30 Thread Thomas Nyberg
Hello, I want to do the following: Given a set of (number, value) pairs, I want to create a list l so that l[[toString(number)]] returns the vector of values associated to that number. It is hundreds of times slower than the equivalent that I would write in python. I'm pretty new to R so I be

Re: [R] Using readLines on a file without resetting internal file offset parameter?

2014-10-29 Thread Thomas Nyberg
entire file (or url, etc.), examining the results, and trying again with a different parsing scheme. In that case the default behavior works well. In any case, I assume the behavior is documented in help("file"). Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Oct 29, 2014 at 9:

Re: [R] Using readLines on a file without resetting internal file offset parameter?

2014-10-29 Thread Thomas Nyberg
ous 2 lines > readLines(f, n=1) [1] "a" > readLines(f, n=1) [1] "b" > readLines(f, n=2) [1] "c" "d" > close(f) I/O operations on an unopened connection generally open it, do the operation, then close it. Bill Dunlap TIBCO Softw

[R] Using readLines on a file without resetting internal file offset parameter?

2014-10-29 Thread Thomas Nyberg
Hi everyone, I would like to read a file line by line, but I would rather not load all lines into memory first. I've tried using readLines with n = 1, but that seems to reset the internal file descriptor's file offset after each call. I.e. this is the current behavior: --- bash $ echo 1

[R] readChar maxing out at screen width when using gnu screen?

2014-10-24 Thread Thomas Nyberg
I am running: R version 3.1.1 (2014-07-10) -- "Sock it to Me" Platform: x86_64-unknown-linux-gnu (64-bit) It is an Amazon 64 Linux instance with the following version: 3.3.4-5.fc17.x86_64 I compiled R myself as well as the newest version of gnu screen. I create a file with a couple hundred