Hi,
Use `drop=FALSE`.
 b<- matrix(c(2,1,-1,-2),ncol=1)
 b[1:3,1]
#[1]  2  1 -1
 b[1:3,1,drop=FALSE]
#or
b[1:3,,drop=FALSE]
#     [,1]
#[1,]    2
#[2,]    1
#[3,]   -1


A.K.



hi all, 

i got a small question tonight. 
> matrix(b,4)[] 
     [,1] 
[1,]    2 
[2,]    1 
[3,]   -1 
[4,]   -2 
> dim(matrix(betan,4)) 
[1] 4 1 
As shown, b is a 4X1 matrix. 

> matrix(betan,4)[1:3,1] 
[1]  2  1 -1 

However, I think the result should be 
     [,1] 
[1,]    2 
[2,]    1 
[3,]   -1 

How could I get the result above? 
Many thanks,

______________________________________________
R-help@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.

Reply via email to