I have a table, read from a file, and I would like to display only rows which have a specific value in a given column. The specific value is a string (e.g. Agricultural). I am able to do it using the following code if the value is an integer:
\pgfplotstabletypeset[row predicate/.code={%
\pgfplotstablegetelem{#1}{variable}\of{test.txt}
\ifnum\pgfplotsretval=3\relax
\else\pgfplotstableuserowfalse\fi}]{test.txt}
The value I am looking to match is "Agricultural." I have tried to use \if and \ifx but this was not successful.
Any input helps! Thanks!
Edit:
MWE:
\documentclass{article}
\usepackage{float}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstabletypeset[row predicate/.code={%
\pgfplotstablegetelem{#1}{variable}\of{test.txt}
\ifnum\pgfplotsretval=3\relax
\else\pgfplotstableuserowfalse\fi}]{test.txt}
\end{document}
test.txt:
variable 2016 2017 2018
2 0.16519 0.1519385 0.1924408
Agricultural 0.4751213 0.3346962 0.2863951
3 0.0868261 0.1613692 0.2666448
3 0.4510618 0.5404901 0.5006156
