How am I able to calculate two linear regressions basing on the meta-data?
In my example I want to have one linear regression for the green points and one for the red points.
\documentclass[preview, border={10pt}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{pgfplotstable}
\begin{filecontents*}{datatable.txt}
one two letter
9 7 g
9 6 g
8 1 g
7 3 g
6 5 g
6 5 g
5 2 g
4 8 r
3 9 r
3 2 r
3 1 r
2 3 r
1 2 r
\end{filecontents*}
\begin{document}
\centering
\begin{tikzpicture}
\begin{axis}[
scatter/classes={
g={mark=*,green},
r={mark=*,red}
}
]
\addplot [scatter,only marks,scatter src=explicit symbolic] table [x=one, y=two, meta=letter] {datatable.txt};
\addplot [blue, no markers] table [x=one,y={create col/linear regression={y=two}}] {datatable.txt};
\end{axis}
\end{tikzpicture}
\end{document}
