similar to: weekly update 20081208

Displaying 20 results from an estimated 6000 matches similar to: "weekly update 20081208"

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 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,
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
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 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
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
2009 Mar 09
1
detecting NULL in recursive lists
Dear R-users, How can I detect a NULL in a recursive list? For a regular list I could use lapply: > lapply(list(x=NULL), is.null) $x [1] TRUE However that doesn't work for structures like list(list(x=NULL)). I tried rapply but it treats NULL as a list and discards them: > rapply(list(a=1, b=list(x=NULL)), is.null) a FALSE Any suggestion? Thank you for your help, Vadim Note:
2009 Jul 21
0
building source package in R run within Emacs under Windows.
Dear R-devel, I installed R-2.9.1 on the 'y:' drive which happens to be mounted to an IBRIX file system. I also downloaded and installed the Rtools bundle recommended for 2.9x. When I build a source package launching R via RGui.exe it seems to work fine: ## setting path according to "Appendix E The Windows toolset" >
2009 Jul 21
1
bug in approx crashes R
Dear R-devel, The following line crashes R > approx(1, 1, 0, method='const', rule=2, f=0, yleft=NULL, ties='ordered')$y Process R:2 exited abnormally with code 5 at Tue Jul 21 14:18:09 2009 > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 9.1 year
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)
2009 Mar 13
1
lsfit w/ rank-deficient x
Dear R-devel, It seems that lsfit incorrectly reports coefficients when the input matrix 'x' is rank-deficient, see the example below: ## here values of 'b' and 'c' are incorrectly swapped > x <- cbind(a=rnorm(100), b=0, c=rnorm(100)); y <- rnorm(100); lsfit(x, y)$coef Intercept a b c -0.0227787 0.1042860 -0.1729261 0.0000000 Warning
2010 Sep 01
2
testing for emptyenv
Dear R-users, Is there a way to test whether a particular environment e is equal to emtyenv(), or for that sake whether two environments e1 and e2 are equal? I tried a couple of ways to compare environments, but neither seem to work: > e1 <- new.env() > e2 <- new.env() > e1 == e2 Error in e1 == e2 : comparison (1) is possible only for atomic and list types > all.equal(e1,
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
2011 Mar 14
1
discrepancy between lm and MASS:rlm
Dear R-devel, There seems to be a discrepancy in the order in which lm and rlm evaluate their arguments. This causes rlm to sometimes produce an error where lm is just fine. Here is a little script that illustrate the issue: > library(MASS) > ## create data > n <- 100 > dat <- data.frame(x=rep(c(-1,0,1), n), y=rnorm(3*n)) > > ## call lm, works fine > summary(lm(y ~
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;
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