similar to: extracting the i-th row of a matrix in a list of lists

Displaying 20 results from an estimated 10000 matches similar to: "extracting the i-th row of a matrix in a list of lists"

2012 Mar 11
2
Efficient access to elements of a list of lists
Hi, I have a long list of lists from which I want to efficiently extract and rbind elements. So I'm using the approach below: f <- function(i){ out <- replicate(5, list(matrix(rnorm(80), nc=20))) names(out) <- letters[1:5] out } set.seed(1) lst <- lapply(1:1.5e6, f) (t0 <- system.time(tmp <- do.call(rbind, lapply(lst, '[[', 'b')))) Is there
2012 Mar 26
2
read.csv and field containing single quotes
I need to read in csv files, created by 3rd party, with fields containing single quotes (as shown below). "header1","header2","header3","header4" "field1r1","field2r1","field3r1","field4r1" "field1r2","field2r2","field3r2PartA), field3r2PartB Very" Long","field4r2"
2012 Feb 18
4
assigning NULL to a list element
Hi everyone, For reasons beyond the scope of this message, I'd like to append a NULL element to the end of a list. tmp0 <- list(a=1, b=NULL, c=3) append(tmp0, c(d=4)) ## works as expected append(tmp0, c(d=NULL)) ## list with a/b/c only Given that I could use tmp0$a <- NULL to remove 'a', I seem to understand why appending NULL returns me the original list... But how should I
2012 Jul 07
1
creating a '[' method for an S4 class
Hi, I'm working on an S4 class that is expected to behave like an array. I have some difficulties when defining '[' and I wonder if someone could point me to the right direction: 1) Call the S4 object "obj" 2) Assume dim(obj) = c(10, 4, 2) 3) Suppose someone calls: obj[1:3,] , which is a mistake, given dim(obj); how do I detect such situations? Thank you very much for
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem
2011 Jul 22
2
Extracting components from a 'boot' class output in R
Dear R user, I used the following to do a bootstrap. >bootObj<-boot(data=DAT, statistic=Lp.est, R=1000,x0=3) I have the following output from the above bootstrap. How can I extract  components of the output. For example, how can I extract the std.error? > bootObj   ORDINARY NONPARAMETRIC BOOTSTRAP   Call: boot(data = DAT, statistic = Lp.est, R = 1000, x0 = 3)   Bootstrap Statistics
2006 Nov 29
1
tests for NULL objects
Hi Everyone, After searching the subject and not being successful, I was wondering if any you could explain me the idea behind the following fact: all(NULL == 2) ## TRUE any(NULL == 2) ## FALSE Thanks a lot, Benilton -- Benilton Carvalho PhD Candidate Department of Biostatistics Johns Hopkins University
2007 Aug 07
1
Naming Lists
Hi Im pretty new to R and I have run in to a problem. How do I name all the levels in this list. Lev1 <- c("A1","A2") Lev2 <- c("B1","B2") Lev3 <- c("C1","C2") MyList <- lapply(Lev1,function(x){ lapply(Lev2,function(y){ lapply(Lev3,function(z){ paste(unlist(x),unlist(y),unlist(z)) })})}) I would like to name the different
2009 Oct 13
7
lapply() reccursively
Hi all, I was wondering whether it is possible to use the lapply() function to alter the value of the input, something in the spirit of : a1<-runif(100) a2<-function(i){ a1[i]<-a1[i-1]*a1[i];a1[i] } a3<-lapply(2:100,a2) Something akin to a for() loop, but using the lapply() infrastructure. I haven't been able to get rapply() to do this. The reason is that the "real"
2007 Nov 29
1
extracting items from R objects and using them in \Sexpr with Sweave--problem with $
Running R 2.5.1 on WinXP with Tinn-R, and using Sweave via MikTex. I am having trouble with the code below: ------------------------------------------------------- <<lowerCI95>>= lowerCI95713 <- t.test(data713, alternative="greater") lowerCI95713.bound <- lowerCI95713$conf.int[1] @ Thus a lower 95\% confidence bound on the mean octane concentration is
2003 Jul 10
2
Administrative Share
Hi everybody, I've been looking for information on "how to create administrative shares", but I didn't find... Can you help me on this matter? Regards, -- Benilton Carvalho DE / IMECC / UNICAMP Red Hat Linux i18n Team
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:
2007 Jan 19
1
Suggestion on how to improve efficiency when using MASS:::hubers on high-dimensional arrays
Hi Everyone, Given the scenario I have, I was wondering if anyone would be able to give me a hind on how to get the results from hubers() in a more efficient way. I have an outcome on an array [N x S x D]. I also have a factor (levels 1,2,3) stored on a matrix N x S. My objective is to get "mu" and "sigma" for each of the N rows (outcome) stratified by the factor
2009 May 09
1
Strip labels: use xyplot() to plot columns in parallel with outer=TRUE
The following tinkers with the strip labels, where the different panels are for different levelf of a conditioning factor. tau <- (0:5)/2.5; m <- length(tau); n <- 200; SD <- 2 x0 <- rnorm(n, mean=12.5, sd=SD) matdf <- data.frame( x = as.vector(sapply((0:5)/2.5, function(s)x0+rnorm(n, sd=2*s))), y <- rep(15+2.5*x0, m), taugp = factor(rep(tau, rep(n,m)))) names(matdf)
2007 May 11
4
names of objects in .rda
Hi everyone, sorry if this was discussed before (and in this situation, could you please point me to the discussion in the archive? My search didn't seem to be effective). Is there a way of getting the names of objects in a .rda file without having to load it? Thank you very much, benilton -- PhD Candidate Department of Biostatistics Bloomberg School of Public Health Johns Hopkins
2003 Jul 10
2
DIAGNOSIS.TXT
Hi all, working on the problem that I cannot log in from my NT4 box I noticed that: - Test 8 from DIAGNOSIS.TXT fails: from the NT machine I try: "net view \\server" and I have: "System error 5 has occurred. Access denied" I don't know how to handle this... Could you please help me? Regards, -- Benilton Carvalho DE / IMECC / UNICAMP Red Hat Linux i18n Team
2008 Jul 08
3
extracting index list when using tapply()
Hello, The quick version of my question is how can I extract a matrix instead of a vector using tapply()? I would like to be able to access both the results of tapply() and also the index variables. In case further explanation would help: I am analyzing a large (3million rows x 9 columns) spatial/temporal dataset and am attempting to calculate the number of unique years containing any data
2007 Jun 06
2
name of the variable that will contain the result of a function
Hi everyone, say I have a function called 'foo', which takes the argument arg1. Is there any mechanism that I can use to "learn" about the variable where foo(arg1) is going to be stored? For example: x <- foo(arg1) so, inside foo() I'd like to be able to get the string "x". if, foo(arg1) was used insted, I'd like to get NA. thank you very much, b
2008 Dec 31
3
Plotmath with values?
I hope to use the plotmath facility to print titles that mix math and values of R variables. The help for "plotmath" has an example, which after repeated reading, I find baffling. Likewise, I have read the help file for "substitute" (wqhich seems to be needed) without ever understanding what it does, other than being used in some magic incantations. I would like to do
2006 Jan 17
1
data.matrix returns mode logical for zero rows (PR#8496)
Full_Name: Jonathan Swinton Version: 2.2.1 OS: Windows Submission from: (NULL) (193.132.159.169) #The first line of description for data.matrix says that it will # 'Return the matrix obtained by converting all the variables in a # data frame to numeric mode and then binding them together as the # columns of a matrix.' #However when called with a data.frame with zero rows,