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.
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.
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/rstats/comm...