search for: zidx

Displaying 2 results from an estimated 2 matches for "zidx".

Did you mean: idx
2011 Sep 08
3
How to specify a variable name in the regression formula without hard coding it
...ms. The variable name of y can change, so I don't want to hardcode it. I can find out the name as follows: > names(mat)[y] [1] "er12.l" Then I can run the regression by hard coding the variable name as follows: > mod <- try(rlm(er12.l ~ ., data=mat[zidx, c(y, x)]), silent=TRUE) But how would I do so without hard coding the name er12.l? I set up a reproducible example. In the following my regression formula is aa ~ bb + cc, or more simply aa ~ . How can I use the name of the first column without hard coding aa? dat <- data.frame(aa=runif(50)...
2011 Sep 08
2
Variable scoping question
...y(ls(), function(w) object.size(get(w))) as.matrix(rev(sort(z))[1:5]) } mysize() When I test the lines inside the function it works fine: > z <- sapply(ls(), function(w) object.size(get(w))) > as.matrix(rev(sort(z))[1:5]) [,1] mat 166344288 mod 130794704 zidx 799664 wfidx 799664 megacap 799664 > But when I try to run the function, it produces an error: > "mysize" <- function() { + z <- sapply(ls(), function(w) object.size(get(w))) + as.matrix(rev(sort(z))[1:5]) + } > mysize() Error in rev(sort(z)) : e...