I would like to create a sequence of theta (1,100),(2,100),(3,100)...(100,100)
theta[1]
is seq(from = 1 , to = 100 , length =100)
theta[2]
is 1
How should I define theta?
I think your are just looking for a matrix somehow, or a data.frame. I guess you actually want theta[2] = 100
to make sense. So
theta = matrix(c(seq(1,100),rep(1,100)),nrow = 100,ncol = 2)
will give you the pair in each row theta[n,], and from your definition theta[1]
will now be theta[,1]
, theta[2]
will be theta[,2]
Just create your two sequences, and row-bind them:
theta = rbind(seq(from=1, to=100, length=100), rep(100,100))
Now your theta
will look like this:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] ...
[1,] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
[2,] 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...
and theta[1,]
will be a sequence from 1 to 100, and theta[2,]
a sequence of all 100s of size 100.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.