[R] Indexing within by statement - different coloured lines in abline wanted..
jrkrideau at inbox.com
Mon May 27 15:08:17 CEST 2013
Slightly diffferent approach but will this do what you want.
ggplot(Data1, aes(Predictor, Response1, colour = Site)) +
geom_smooth(method= "lm", se = FALSE) +
ggtitle("Raw data with linear regresssions by Site")
Kingston ON Canada
> -----Original Message-----
> From: tom.wilding at sams.ac.uk
> Sent: Mon, 27 May 2013 10:39:58 +0000
> To: r-help at r-project.org
> Subject: [R] Indexing within by statement - different coloured lines in
> abline wanted..
> Dear R-list
> I'm trying to get each regression line, plotted using abline, to be of a
> different colour as the following code illustrates. I'm hoping there is
> a simple indexing solution. Many thanks.
> ## code from here
> #create data frame
> pch=as.numeric(Site),main="Raw data with linear regresssions by
> abline(lm(Response1~Predictor,data=Site),col=colours)#index in here.
> The Scottish Association for Marine Science (SAMS) is registered in
> Scotland as a Company Limited by Guarantee (SC009292) and is a registered
> charity (9206). SAMS has an actively trading wholly owned subsidiary
> company: SAMS Research Services Ltd a Limited Company (SC224404). All
> Companies in the group are registered in Scotland and share a registered
> office at Scottish Marine Institute, Oban Argyll PA37 1QA. The content of
> this message may contain personal views which are not the views of SAMS
> unless specifically stated. Please note that all email traffic is
> monitored for purposes of security and spam filtering. As such individual
> emails may be examined in more detail.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
Share photos & screenshots in seconds...
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if1
Works in all emails, instant messengers, blogs, forums and social networks.
More information about the R-help