PGFPlots ! 未定義の制御シーケンス。\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@

PGFPlots ! 未定義の制御シーケンス。\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@

これは、先ほど質問した、そこでは、プロットされていない変数の値に基づいてデータの行を選択しようとしていました。その質問への回答に従って、どの行を含めるかを決定するために「x expr」と「\thisrow」を使用しています。

しかし、私は以下のように\foreachループでコードを使いたいです(データを含めていないので完全なMWEではありません。データが必要と思われる場合は、いくつかの例を追加します)。エラーが引き続き発生します。

! Undefined control sequence.
\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ 

StackExchange の質問によると、これはマクロの展開に関連するさまざまな理由で発生するようです。この場合、このエラーを回避する方法はありますか?

\documentclass[12pt]{article}

\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=1.15}

\newcommand{\dir}{n:/pathtodata}


\begin{document}

\newcommand{\outcomestest}{
  attn/Attendance,
  enrollall_00/Enrollment,
  all_mth00pctprof_00/Math Proficiency,
  all_rla00pctprof_00/Reading Proficiency}



\foreach \outcome/\label in \outcomestest{
  \begin{tikzpicture}
    \begin{axis}[ymin=-30,ymax=30,title=\label, xlabel=Year]
      \draw [red](axis cs:-4,0) -- (axis cs:2,0);
      \addplot table [x expr={\thisrow{bias}==1?nan:\thisrow{period}},y=b]{\dir/main_\outcome_primary.txt};
      \addplot table [x expr={\thisrow{bias}==0?nan:\thisrow{period}},y=b]{\dir/main_\outcome_primary.txt};
    \end{axis}
  \end{tikzpicture}}

\end{document}

ありがとう!

関連情報