-1

I would like to know, how I can plot cluster of time-series with different colors, when I'm using loop. I know that the procedure ggplot() do it, but I cannot use it before loop. Here is the code:

plot(units_sold[,1], t="l", ylim=c(0,4500))

for (i in 2:126) { 
  if (klaster1[i,2] == "1")
    lines(units_sold[,i])
}

Where should I put in the code the option to plot every time-series in cluster with different color?

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
user3463225
  • 401
  • 9
  • 19

1 Answers1

0
plot(units_sold[,1], t="l", ylim=c(0,4500))

for (i in 2:126) 
 { 
   if (klaster1[i,2] == "1")
   lines(units_sold[,i], col = colors()[i])
  }

You can improve colors using some color palette system.

FFI
  • 392
  • 1
  • 10