This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
Creating a list of unique colors to iterate through for a scatter plot
Post Body

Greetings people who are good at R,

I come to you in a time of great need. I am a masters student in a non-quantitative field (strength and conditioning) and am using R to analyze my thesis data. I'm currently scheduled to defend on May 5th, but need to add graphs to my document first. My stats advisor has sent me the necessary R code to generate the graphs with the variables I want visualized. Now, the only thing I need to do on my own, is make sure there's no doubles in the color for the scatterplot. It was described to me that R only has a few default colors, but that I should be able to find hexadecimal codes or something to make a list of 14 unique colors, then iterate through that to make sure each participant is a unique color. I will copy the code for one plot below, but if anyone can help me modify it to simply have each of 14 participants be a different color I would forever be in your debt!

  # Plot relative power vs. total distance
plot(data$Distance,data$Mean_W_Kg,pch="",
     ylab="Relative Power (w/kg)",
     xlab="Total Distance (km)",
     main="Relative Power vs. Total Distance (km)")
for(i in 1:length(unique(data$Player))){
  sub <- subset(data, Player==unique(data$Player)[i])
  lines(sub$Distance,sub$Mean_W_Kg,col=i)
  points(sub$Distance,sub$Mean_W_Kg,col=i,pch=19)
}
abline(a=51.57,b=.23,lwd=3,lty=2,col="lightgrey")

I have this same block but with different variables for three other plots. My advisor said its possible to create a variable that's a list of 14 colors, then iterate through it and reference it at index "i". Alas, I know very little R and require assistance.

Author
Account Strength
90%
Account Age
5 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,742
Link Karma
937
Comment Karma
805
Profile updated: 1 day ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago