similar to: making array of lists

Displaying 20 results from an estimated 3000 matches similar to: "making array of lists"

2008 Mar 21
2
writintg wrappers around save()
Dear R-users, I am trying to write a wrapper function around save() that will report the file which is being saved to. So I thought that the followintg would do the trick, but it doesn't. I understand that 'y' is somehow not visible inside save.verbose, but don't know how to fix this. save.verbose <- function(..., file) { cat("save.verbose:", file, "\n")
2008 Oct 03
2
computing on expressions
Dear R-users, Suppose I have an expression: expr = expression(a>0) and now I want to modify it to expression(a>0 & b>0). The following doesn't work: expr = expression(expr & b>0) What would be a good way of doing this? Thanks, Vadim ________________________________ Note: This email is for the confidential use of the named addressee(s) only and may contain
2008 Aug 20
1
names of return value of median
Dear R-devel, The median() function assigns a name, "NA", to its return value if the return value is NA and the input vector has names, otherwise the names attribute is NULL. This looks strange and inconsistent with the behavior of mean(). This inconsistency becomes a problem when median() is used inside user code that relies on consistent naming convention. Thanks, Vadim > foo
2008 Feb 25
1
how to write dput-able objects
Hi, One way of doing object-oriented programming in R is to use function environment to hold object's data, see for example @Article{Rnews:Chambers+Lang:2001a, author = {John M. Chambers and Duncan Temple Lang}, title = {Object-Oriented Programming in {R}}, journal = {R News}, year = 2001, volume = 1, number = 3, pages = {17--19},
2008 Sep 04
1
lapply(NULL, ...) returns empty list
Dear R-devel, Is there a reason that lapply(NULL, ...) returns the empty list, rather than NULL? It seems intuitive to expect the latter, and rather counterintuitive that lapply(list(), ... ) returns the same value as lapply(NULL, ...). > lapply(list(), function(x) 1) list() > lapply(NULL, function(x) 1) list() > version _ platform i386-pc-mingw32 arch
2007 Dec 17
1
names in Rscript -e
Hi, I seem to have a problem when passing named parameters to R via Rscript (R2.5.1, bash shell). As soon as I name elements of a list Rscript generates an error. I will appreciate if someone could point to me a correct way of doing this. Thanks, Vadim ## This works bash-3.2$ Rscript.exe -e 'list(1)' [[1]] [1] 1 # and these do not work bash-3.2$ Rscript.exe -e
2007 May 03
2
convert text to exprission good for lm arguments
Hi, I ran into a problem of converting a text representation of an expression into parsed expression to be further evaluated inside lm (). > n <- 100 > data <- data.frame(x= rnorm (n), y= rnorm (n)) > data. lm <- lm (y ~ x, data=data) > > ## this works > update(data. lm , subset=x<0) Call: lm (formula = y ~ x, data = data, subset = x < 0)
2007 Feb 14
1
Snow vs Rmpi
Hi, I have few high-level questions about the Snow and Rmpi packages . I understand that Snow uses Rmpi as one of possible transport layers, yet my questions about user experience, not technical details: 1. Does Snow install and work well in Windows? 2. Interruptibility. I understand that currently it is impossible to interrupt a running top-level command in Snow ( Ctl-c or the likes), the
2008 Feb 26
1
error loading library
Hi, I am debugging intermittent crashes of R that seem to happen when multiple R sessions nearly summaltaneously load same dll-based library. I have R and my libraries installed on a network drive (everything is Windows). The drive is visible from a farm of servers. I have an R script, foo.R, that just loads a dll-based library (to be precise it loads a library that requires a dll-based
2007 May 18
1
subset arg in (modified) evalq
Hi, When using evalq to evaluate expressions within a say data.frame context I often wish there was a 'subset' argument, much like in lm() or any ather advanced regression model. I would be grateful for a tip how to do this. Here is an illustration of what I want: n <- 100 data <- data.frame(x=rnorm(n), y=rnorm(y), z=rnorm(z)) # this works evalq({ i <- 0<x;
2010 Oct 15
1
calling browser on error
Dear R-developers, I am trying to figure out a way to call browser() when an error occur, and naturally I want the browser() to be called in the environment of the error. I tried something simple in vain: > f <- function() { x <- 1; stop('ok') } > tryCatch(f(), error=browser()) Called from: tryCatch(f(), error = browser()) ## if browser() was called in the local environment
2009 Jul 21
1
subscript into matrix discards row/column names
Dear R-help, When the result of a matrix subscription degenerates to a scalar the names implied by the dimnames are discarded. > x <- matrix(0, 1, 1, dimnames=list('a', 'x')) ## below I expected result to have names='x', it's not > x[1,] [1] 0 ## below I expected result to have names='a', it's not > x[,1] [1] 0 This is probably a side effect
2008 Nov 28
1
names generated in list indexing
Dear R-devel, When a character vector is used to subscript a list and when some of the subscripts are not present in the list names R returns NULL for those subscripts and generate NA names for each of them: > list(b=1)[c('a','b')] $<NA> <<-- generated name NULL $b [1] 1 Wouldn't it be more intuitive to use the subscript name rather than to generate an NA?
2010 Jun 26
2
subset arg in subset(). was: converting result of substitute to 'ordidnary' expression
Dear R users, Please disregard my previous post "converting result of substitute to 'ordidnary' expression". The problem I have has nothing to do with substitute. Consider: > dat <- data.frame(x=1:10, y=1:10) > subsetexp <- expression(5<x) > ## this does work > subset(dat, eval(subsetexp)) x y 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 > ##
2010 Dec 23
2
data frame with nested data frame
Dear R-users, I am somewhat puzzled by how R treats data frames with nested data frames. Below are a couple of examples, maybe someone could help explain what the guiding logic here is. ## construct plain data frame > z <- data.frame(x=1) ## add a data frame member > z$y <- data.frame(a=1,b=2) ## puzzle 1: z is apparently different from a straightforward construction of the
2017 Mar 20
1
outer not applying a constant function
> Or is this a bad idea? I don't like the proposal. I have seen code like the following (in fact, I have written such code, where I had forgotten a function was not vectorized) where the error would have been discovered much later if outer() didn't catch it. > outer(1:3, 11:13, sum) Error in outer(1:3, 11:13, sum) : dims [product 9] do not match the length of object [1]
2010 Jun 26
3
converting result of substitute to 'ordidnary' expression
Dear R users, As substitute() help page points out: Substituting and quoting often causes confusion when the argument is 'expression(...)'. The result is a call to the 'expression' constructor function and needs to be evaluated with 'eval' to give the actual expression object. And indeed I am confused. Consider: > dat <- data.frame(x=1:10,
2010 Jun 26
3
converting result of substitute to 'ordidnary' expression
Dear R users, As substitute() help page points out: Substituting and quoting often causes confusion when the argument is 'expression(...)'. The result is a call to the 'expression' constructor function and needs to be evaluated with 'eval' to give the actual expression object. And indeed I am confused. Consider: > dat <- data.frame(x=1:10,
2008 Jul 23
2
shQuote and cat
Dear R-users, It is my understanding that cat(shQuote(a.string)) should print the origintal a.string. Is this right? I am not sure cat() correctly prints strings which are generated by triple-shQuote(): > shQuote(shQuote("a")) [1] "\"\\\"a\\\"\"" > cat(shQuote(shQuote(shQuote("a"))), '\n')
2008 Jul 23
2
shQuote and cat
Dear R-users, It is my understanding that cat(shQuote(a.string)) should print the origintal a.string. Is this right? I am not sure cat() correctly prints strings which are generated by triple-shQuote(): > shQuote(shQuote("a")) [1] "\"\\\"a\\\"\"" > cat(shQuote(shQuote(shQuote("a"))), '\n')