I have a variable a=0.01
I then create a matrix b<-matrix(data=NA,ncol=2,nrow=9)
I would like to rename this matrix by adding the value stored in a to its name.
The results should be b_0.01
I have a variable a=0.01
I then create a matrix b<-matrix(data=NA,ncol=2,nrow=9)
I would like to rename this matrix by adding the value stored in a to its name.
The results should be b_0.01
I bet there are more elegant ways to achieve what you need, but this seems to work:
assign(x = paste("b", a, sep = "_"), value = b)
Edit following @Roland's comment:
rm(b)
Please note that I address your question in a narrow sense. As pointed out by both @Roland and @Paul Hiemstra, there may be more general aspects of the work-flow that could be fruitful to consider as well.
rm(b).rm. I entirely agree that this is not renaming per se - it was just my best alternative. I would be happy to see pure renaming solution. And yes, I support your comment to OP.