On Apr 6, 2012, at 00:25 , ikuzar wrote:
> Hi,
>
> I'd like to know how to get a vector of min value from many vectors
without
> making a loop. For example :
>
>> v1 = c( 1, 2, 3)
>> v2 = c( 2, 3, 4)
>> v3 = c(3, 4, 5)
>> df = data.frame(v1, v2, v3)
>> df
> v1 v2 v3
> 1 1 2 3
> 2 2 3 4
> 3 3 4 5
>> min_vect = min(df)
>> min_vect
> [1] 1
>
> I 'd like to get min_vect = (1, 2, 3), where 1 is the min of v1, 2 is
the
> min of v2 and 3 is the min of v3.
>
> The example above are very easy but, in real, I have got v1, v2, ... v1440
sapply(df, min)
(possibly sapply(df, min, na.rm=TRUE) )
>
> Thanks for your help,
>
> ikuzar
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/how-to-compute-a-vector-of-min-values-tp4536224p4536224.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com