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

Daniel Malter daniel at umd.edu
Sun Jun 19 16:15:44 CEST 2011


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.

x<-list(c(1,5),c(2,3,4))
lapply(x,min)
min(unlist(x))

HTH,
Daniel


jiliguala wrote:
> 
> 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.
> 
> ##  which(list1==min(list1)).
> 
> thanks for helping
> 

--
View this message in context: http://r.789695.n4.nabble.com/how-to-get-the-miminum-value-in-the-list-tp3609013p3609325.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list