Re: [R] how to get the miminum value in the list

2011-06-20 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 19.06.2011 20:45:04: Hi: It's just an extra step: y - list(list(c(1,5),c(2,3,4)), list(c(1, 3, 4), c(5, 7))) lapply(seq_len(length(y)), function(i) lapply(y[[i]], min)) [[1]] [[1]][[1]] [1] 1 [[1]][[2]] [1] 2 [[2]] [[2]][[1]] [1] 1

[R] how to get the miminum value in the list???

2011-06-19 Thread jiliguala
hi, R users here i have one problem, if i wanna get the minimum value in the normal data, i can do this, ## which(data1==min(data1)). but if i want get the minimum value of a list which has two variables ##list1[[j]][[i]]##, i tried the codes like this, but it did not work. ##

Re: [R] how to get the miminum value in the list

2011-06-19 Thread Daniel Malter
Hi, that depends on whether you want to get the minimum within each list element or the global minimum across all list elements. The first is achieved by using lapply(). The second can be achieved by unlisting the list (which assumes that all list elements are numeric) and looking for its minimum.

Re: [R] how to get the miminum value in the list

2011-06-19 Thread jiliguala
but in my case, the list is a two-variable list, list[[j]][[i]] when i use lapply(list, min) it appears Error in FUN(X[[1L]], ...) : invalid 'type' (list) of argument thanks -- View this message in context:

Re: [R] how to get the miminum value in the list

2011-06-19 Thread Dennis Murphy
Hi: It's just an extra step: y - list(list(c(1,5),c(2,3,4)), list(c(1, 3, 4), c(5, 7))) lapply(seq_len(length(y)), function(i) lapply(y[[i]], min)) [[1]] [[1]][[1]] [1] 1 [[1]][[2]] [1] 2 [[2]] [[2]][[1]] [1] 1 [[2]][[2]] [1] 5 unlist(lapply(seq_len(length(y)), function(i) lapply(y[[i]],