Peter showed how to get the minimums from a list or data frame using
sapply, here is a way to copy your 1440 vectors into a single list
(doing this and keeping your data in a list instead of separate
vectors will make your life easier in general):
my.list <- lapply( 1:1440, function(x) get( sprint
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
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
Hello,
Try
apply(df, 2, min)
(By the way, 'df' is the name of a R function, avoid it, 'DF' is better.)
Hope this helps,
Rui Barradas
--
View this message in context:
http://r.789695.n4.nabble.com/how-to-compute-a-vector-of-min-values-tp4536224p4536275.html
Sent from the R help mailing list a
4 matches
Mail list logo