Suppose I am running a forloop that runs 15 times, each time the forloop uses the plot() function with a different colour
colours<- c()
for(i in 1:15){
plot( ... , col = i)
colours[i] <- i
}
Is it possible to some how replace the numbers with the actual names of the colours so when I refer pack to the plots, I can see what iteration of the loop gave that colour. Without replacement, the vector colours
will just end up looking like
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
CodePudding user response:
If you name the colors in colours
, the loop will work. Use either R's named colors (some