'Forming linear model from data split into two groups to form two gradients

enter image description here

I was wondering how I would be able to form a linear model of Lscd (y axis) vs Risk (x axis) but splitting up the replicative cluster into one gradient and the determinisitic into another gradient.

I know how to form the linear model easily of Lcsd vs Risk without any groups

model <- lm(Lscd~Risk, data=cancer)

but I can't figure how to extract the two groups into a model.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source