search for: mylist2

Displaying 8 results from an estimated 8 matches for "mylist2".

Did you mean: mylist
2011 Apr 05
1
Help in splitting a list
...h components being 'm' matrices (as exemplified in the "mylist" object below). Now, I'd like to subset this list based on an index vector, which will partition each matrix 'm' in 2 sub-matrices. My questions are: 1. Is there an elegant way to have the results shown in mylist2 for an arbitrary number of matrices in mylist? 2. The column names are 'lost' for mylist2[[2]] and mylist2[[4]] (but not for mylist2[[1]] and mylist2[[3]]). Is there a way to keep the column names in the results of mylist2? mylist <- list(matrix(1:9,3,3), matrix(10:18,3,3)) colnames(my...
2013 Mar 13
2
holding argument(s) fixed within lapply
...expr = substitute(f(w, y = Y, z))||| ||| )||| |||| |||# now, the part I'm stuck on is for a version of f where z has a default||binding| |||f2 <- function(w, y, z = 0){ w + y + z }||| |||| |||# the same as mylist, but now z is optional||| |||mylist2 <- list(one = list(w = 1),||| ||| two = list(w = 3, z = 4)||| ||| )||| |||| |||# undesired result||(first element has length 0)| |||ret2 <- lapply(FUN = function(x,...) f2(w = x$w, z = x$z, ...),||| ||| X = mylist2,|||...
2011 Apr 03
1
Help in splitting ists into sub-lists
...r List, Let's say I have a list whose components are 2 matrices (as exemplified in the "mylist" object below). I'd like to create a list with components being 4 matrices based on an logical index vector. is there a way to simplify what I'm doing to obtain the results in "mylist2"? I'd like something that would work on an arbitrary number of elements in "mylist". mylist <- list(matrix(1:9,3,3), matrix(10:18,3,3)) index1 <- c(TRUE,FALSE,TRUE) index2<- c(FALSE,TRUE,TRUE) mylist2 <- list(mylist[[1]][,index1], mylist[[1]][,i...
2010 Sep 09
0
Fast / dependable way to "stack together" data frames from a list
...ual(resultDF, resultDF5) ## Plyr author Hadley Wickham followed up with "I think all you want here is rbind.fill:" resultDF6 <- rbind.fill(mylist) all.equal(resultDF, resultDF6) ## Gabor Grothendieck noted that if the elements in mylist were matrices, this would all work faster. mylist2 <- lapply(mylist, as.matrix) matrixDoCall <- do.call("rbind", mylist2) all.equal(as.data.frame(matrixDoCall), resultDF) ## Gabor also showed a better way than 'system.time' to find out how ## long this takes on average using the rbenchmark package. Awesome! #> libra...
2010 Feb 19
4
Accessing values of a matrix
hello all, thank you for taking the time I have a matrix A that have column names (let say n columns), I want to reduce the matrix to have just a few of those column (p colums, this is trivial), but for the lines I want only the lines such that A(i,J) is part of a list (J is fixed and known) I am sure it is very easy but I don't find it (I tryed which but it doesn't seem to work) Surely
2008 Sep 16
2
casting a character vector as an object
Greetings, I need to compare the ratios of vector sizes like this: length(object1) / length(object2) I have many vector objects to compare, so I would like to do it in a loop. I created a loop like this: mat1 <- matrix() for (i in 1:6) { for (j in 1:6) { mat1[i,j] <- length( paste("object",i,sep="")) /
2010 Sep 26
4
Problem with unlist
Hello I want to unlist the attached element getting only the first element in each element of the list. The last element of the list looks as this: [[5065]] [[5065]]$Pluv3Meses [1] 274.4 [[5065]]$PluvMesesMedio [1] 378.2667 [[5065]]$Pluv2UltimosMeses [1] 23.33333 So I would like to get for each element of the list the element called Pluv3Meses. The whole list has 5065 elements but when I try to
2010 Oct 28
1
Merging nested lists
Hello All, I have multiple "list of lists" in the form of Mylist1[[N]][[K]]$Name_i, with N=1..6, K=1..3, and i=1..7. Each Name_i is a matrix. I have 30 of these objects Mylist1, Mylist2, ... I would like to merge these lists by each Name_i using rbind, but I couldn't figure out how to do it. What I want at the end is a single "list of lists", again in the form of Mylist[[N]][[K]]$Name_i. Manually doing it is not feasible given the large number of Mylist objects....