0

I am learning R on datacamp and had to use a hint to get this answer, but I do not understand how it works. Why am I able to use 'name' vector as a value for colour and how does ggplot chose which color to plot the lines in the output.

Thank you.

enter image description here

I initially called colour = c("red", "blue", "black") to represent each of Steven, Thomas and Mathew.

Also see the head of the data set (head(selected_names) I am trying to draw a line graph from.

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please [do not post code or data in images](https://meta.stackoverflow.com/q/285551/2372064). If you want to change the colors you'll want to set the scales. See https://stackoverflow.com/questions/6919025/how-to-assign-colors-to-categorical-variables-in-ggplot2-that-have-stable-mappin – MrFlick Aug 14 '23 at 16:53
  • 2
    I expect you will find this chapter helpful: https://r4ds.had.co.nz/data-visualisation.html#aesthetic-mappings – Jon Spring Aug 14 '23 at 18:19

0 Answers0