Hello @mohitarora,
I keep asking a reprex from you. This is not a hobby of mine but necessary to be able to see what is YOUR problem.
If you had tried to deliver a reprex
you would have seen that the data.frame that you included is not a numeric matrix. The code and the data.frame just don't match:
- the
df
data.frame you did not define - the
df[1:"number_of_cols"]
line would never execute - the
mat1
matrix is not defined
A suggestion: remove some quotes in the specification of df1
.
I think I have contributed what I could.