[,3]
[1,] "Equal" "Small" "Small"
[2,] "Big" "Equal" "Small"
[3,] "Big" "Big" "Equal"
>
Thanks
Chunhao
> Date: Tue, 24 Feb 2009 10:02:29 +
> From: pbu...@pburns.seanet.com
>
Patrick Burns wrote:
One possible first step could be:
ifelse(outer(x, x, '>'), 'Big', 'Small')
Second step: use 'lower.tri'.
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" and "A Guide for the Unwilling S User")
Chunhao Tu wrote
One possible first step could be:
ifelse(outer(x, x, '>'), 'Big', 'Small')
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" and "A Guide for the Unwilling S User")
Chunhao Tu wrote:
Hi R users,
I have a question. How can I use for lo
Hi R users,
I have a question. How can I use for loop to do pair comparisons. For
example,
> x<-c(1,2,3)
> result<-matrix(data=NA, nrow=choose(3,2), ncol=1)
> for(i in 1: length(x))
+{ result[i,]<-ifelse(x[i] > x[i+1], yes="Big", no="Small")
+ result}
> result
[,1]
[1,] "Sm
4 matches
Mail list logo