I would like to know how can I list the outputs of my function (it prints out vectors) so that I am able to know how many steps did it require until finding the optimal solution. I have the following code and am just wondering what should I do at the end so that when printing out the vectors, it enumerates them one at a time as well. I am new to Rstudio and do see that some operations that have to do with matrices are not common in other programming languages. I should say that I have already defined another function such as "gradient", but my concern is about the enumeration of the outputs for this particular function.
Sd=function(b0,epsilon=1e-5){
while (norm(gradient(b0))>epsilon) {
num1=(t(b0)%*%Q%*%gradient(b0)-t(y)%*%X%*%gradient(b0))/(t(gradient(b0))%*%Q%*%gradient(b0))
num2=norm(num1)
step=num2*gradient(b0)
b0=b0-step
print(t(b0))
}
}
Thank you for any help I can get.