I have an excel file which contains 250 sheets( 1st sheet contains 250 rows and 11 columns,2nd sheet contains 249 rows and 11 columns, 3rd sheet contains 248 rows and 11 columns and so on). I need only the values of 11th column from all sheets for creating diagonal matrix. I think , First I have to import 11th column values from excel file to R . Based on these values I have to create a diagonal matrix . Please help me
Share
From what you are describing, you really want a triangular matrix, and I will show how to create an upper triangular matrix:
Step 1: create a matrix to receive results:
Step 2: get a function to read n-th sheet’s the n rows in the 11-th column
Step 3: loop over the 250 sheets and put in the matrix rows
There are lots of way this could fail. The obvious one is indexing past the end of the range of data that comes in from the sheets