# pgfplotstable: Conditional post-processing of cell content on a per-column basis

I am trying to add an asterisk to the content of certain cells depending on the cell's content (essentially, adding a marker for significant p-values) but I am having trouble trying to do so on a per-column rather than per-table basis. I adapted an answer to a similar question that colours cells based on their numerical value but that seems to only work when applied to the whole table. If I try to apply the style to a single column (uncommenting the two lines in the example below), I get a Missing number, treated as zero. error that seems to expect a number after the closing square bracket instead of the file name.

\pgfplotstabletypeset [assume math mode=false,
%  columns/a/.style={ % Uncommenting causes #1 to be empty
postproc cell content/.style={
\pgfmathparse{int(less(#1,\bordervalue))}
\ifnum\pgfmathresult=1
$^*$
\else
$^\dagger$
\fi
},
},
%  },
]{mwe.dat}


This seems to be because, once I wrap the postproc cell content style in a column style, it no longer has access to the contents of that cell. #1, @unprocessed cell content, @cell content after rowcol styles, and @preprocessed cell content all equate to nothing, while @cell content always equates to the content of the very last cell of the whole table.

% #1 is empty when wrapped in a column style
\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.style={
},
},
]{mwe.dat}


% @cell content contains the last cell of the whole table
\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.style={
},
},
]{mwe.dat}


Results are similar when using .code instead of .style:

% Using .code, @cell content still only contains the very last cell of the table
\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.code={%
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfkeysvalueof{/pgfplots/table/@cell content}}%
},
},
]{mwe.dat}


Full MWE:

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.7}

\begin{filecontents}{mwe.dat}
a         b         c         d         e
1.7333    1.6472    1.5418    1.4682    1.5740
1.1525    1.2878    1.2652    1.3511    1.5102
1.2181    1.1500    1.2220    1.2425    1.5699
0.9786    1.1051    1.1472    1.3096    1.6757
0.9569    0.9190    1.0433    1.2924    1.4867
\end{filecontents}

\pgfplotstableset{
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
}

\begin{document}

\def\bordervalue{1.4}
\pgfplotstabletypeset [assume math mode=false,
%  columns/a/.style={
postproc cell content/.style={
\pgfmathparse{int(less(#1,\bordervalue))}
\ifnum\pgfmathresult=1
$^*$
\else
$^\dagger$
\fi
},
},
%  },
]{mwe.dat}

\bigskip

\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.style={
},
},
]{mwe.dat}

\bigskip

\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.append code={%
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfkeysvalueof{/pgfplots/table/@cell content}}%
\fi
},
},
]{mwe.dat}

\end{document}

-

You can just use ##1 instead of #1 in your first approach:

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.7}

\begin{filecontents}{mwe.dat}
a         b         c         d         e
1.7333    1.6472    1.5418    1.4682    1.5740
1.1525    1.2878    1.2652    1.3511    1.5102
1.2181    1.1500    1.2220    1.2425    1.5699
0.9786    1.1051    1.1472    1.3096    1.6757
0.9569    0.9190    1.0433    1.2924    1.4867
\end{filecontents}

\pgfplotstableset{
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
}

\begin{document}

\def\bordervalue{1.4}
\pgfplotstabletypeset [assume math mode=false,
columns/a/.style={
postproc cell content/.style={
\pgfmathparse{int(less(##1,\bordervalue))}
\ifnum\pgfmathresult=1
$^*$
\else
$^\dagger$
\fi
},
},
},
]{mwe.dat}

\end{document}

-
It had to be something very simple ... Would you mind explaining what the difference between #1 and ##1 is in this case and/or in general? –  ThomasH Mar 1 '13 at 17:26
It allows you to access the arguments of a nested macro: tex.stackexchange.com/questions/42463/… –  Jake Mar 1 '13 at 17:27