Hi
I am trying to replicate a vector in n rows for comparison purposes with
another matrix.
foo - c(1,2,3)
bar - rbind(foo,foo) # does the trick for 2 rows
bar - rbind(rep(foo,2)) # does something else
How do I generate a matrix with all rows=foo without writing 'foo' n times as
arg?
Thanks,
Using the recyling rule:
bar - matrix(foo, nrow=n, ncol=length(foo), byrow=TRUE)
HTH,
Andy
-Original Message-
From: David Andel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 9:58 AM
To: [EMAIL PROTECTED]
Subject: [R] rbind question
Hi
I am trying to replicate
-Scanned: by amavisd-milter (http://amavis.org/)
X-Spam-Status: No, hits=-5.3 required=5.0 tests=BAYES_01, HAS_ORGANIZATION
version=2.54
X-Spam-Level:
X-Spam-Checker-Version: SpamAssassin 2.54 (1.174.2.17-2003-05-11-exp)
Subject: [R] rbind question
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.1.2
What about:
matrix(rep(foo,2),ncol=length(foo),byrow=TRUE)
-Original Message-
From: David Andel [mailto:[EMAIL PROTECTED]
Sent: 08 July 2003 14:58
To: [EMAIL PROTECTED]
Subject: [R] rbind question
Hi
I am trying to replicate a vector in n rows for comparison purposes
Hi David,
At 15:58 08/07/2003 +0200, vous avez écrit:
Hi
I am trying to replicate a vector in n rows for comparison purposes with
another matrix.
foo - c(1,2,3)
bar - rbind(foo,foo) # does the trick for 2 rows
bar - rbind(rep(foo,2)) # does something else
This is because `rep()' is executed
David Andel wrote:
Hi
I am trying to replicate a vector in n rows for comparison purposes with
another matrix.
foo - c(1,2,3)
bar - rbind(foo,foo) # does the trick for 2 rows
bar - rbind(rep(foo,2)) # does something else
How do I generate a matrix with all rows=foo without writing 'foo' n
On 8 Jul 2003, David Andel wrote:
Hi
I am trying to replicate a vector in n rows for comparison purposes with
another matrix.
foo - c(1,2,3)
bar - rbind(foo,foo) # does the trick for 2 rows
bar - rbind(rep(foo,2)) # does something else
How do I generate a matrix with all rows=foo
do.call(rbind, rep(list(foo), n))
Patrick Burns
Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)
David Andel wrote:
Hi
I am trying to replicate a vector in n rows for comparison purposes with
another