Dear all
I have the following problem.

M <- matrix(0,3,3) # dimension of M is dinamic and this can lead to the  
next subscript

diag(M[1,1]) <- rep(100,1)
#Error in `diag<-`(`*tmp*`, value = 100) :
# only matrix diagonals can be replaced

diag(M[1,1,drop=F]) <- rep(100,1)
#Error in diag(M[1, 1, drop = F]) <- rep(100, 1) :
# incorrect number of subscripts

diag(M[2:3,1:2]) <- rep(100,2)
# works fine

Is there a way to usw diag as replacement function when the input matrix is  
subscript to a one by one matrix. I don't want extra if(dim==1)... etc.

Thanks a lot in advance.
Best regards,
Roger

	[[alternative HTML version deleted]]

