Creating a diagonal matrix? : I want to generate the matrix below by using a R statement.
1)

0 1 1
1 0 1
1 1 0

2)
0 2 3
0 5 0
7 0 0
3)
1 3 5 7
3 7 11 15
7 15 23 31


I need to write a function?diag function doesn;t help for the first question.