[R] Parameter Matrix

arun smartpink111 at yahoo.com
Mon Oct 22 02:26:05 CEST 2012


Hi,

Try this:
new1<-as.data.frame(expand.grid(a=a,b=b,c=c))
 mat1<-as.matrix(new1[order(new1$a),])
 row.names(mat1)<-1:nrow(mat1)
mat1
#  a b c
#1 1 5 1
#2 1 5 6
#3 2 5 1
#4 2 5 6
A.K.




----- Original Message -----
From: Simeon Lisovski <simeon.lisovski at me.com>
To: r-help at r-project.org
Cc: 
Sent: Sunday, October 21, 2012 7:05 PM
Subject: [R] Parameter Matrix

Hallo,
I would like to run a model (differential equations)
with a whole bunch of parameter combinations.

I think the best way of doing this is to put the model
function into a loop and set a matrix with the parameters:
Each row will represent the parameters for one loop. 

I know how to compile such a matrix (via another loop,
or by using rbind etc.). However I hope you guys may have 
a much better solution compiling such a matrix very quick
and straightforward.

Example (very simple):

a <- 1:2
b <- 5
c <- seq(1,10,5)

The Matrix should be:

a    b    c
1    5    1
1    5    6
2    5    1
2    5    6


Any ideas?
Cheers,
Simeon

______________________________________________
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.





More information about the R-help mailing list