Menu

Using R Graphs Want Change Color Line Graphed Based Upon Variable Data Frame Help Make Sug Q43799316

I am using R for graphs. I want to change the color of the linebeing graphed based upon a variable in the data frame. Can you helpor make a suggestion please? I am including my code.Thank you.

MaryMarion

theme_minimal() +
theme(legend.position = “right”)
)
library(ggplot2)
require(scales)
theme_set(

myplot1 <-ggplot(data=df,aes(x=df$Snowfall.R,y=df$Snowfall.B),
shape=df$att, color=as.factor(df$att))+
geom_line()+
geom_point()+
geom_smooth(method=’lm’, col=”grey75″)+
labs(x = “Snowfall,Rochester(in)”, y = “Snowfall,Buffalo(in)”)+
ggtitle(“Buffalo vs Rochester”)+
expand_limits(y=0)+
coord_fixed(ratio=1/3)+
scale_color_manual(1=”blue”, 2=”red”)+
scale_x_continuous(limits=c(0,230),breaks=c(50,100,150,200))+
scale_y_continuous(limits=c(0,230),breaks=c(50,100,150,200))
myplot1

Expert Answer


Answer to I am using R for graphs. I want to change the color of the line being graphed based upon a variable in the data frame. C…

OR