Hello Martin, I believe there are two solutions:
1. You are explicitly assigning columns anyway. You could assign your temporary intermediate solutions to global variables and dereferences that one. This is a dirty hack, I agree. 2. You can safely use \pgfplotstablegetelem{ row }{ col }\of table where row is an integer, 0<=row<number rows and col a column name. Note that row currently has to be a constant (not an expression). You can use \pgfplotstablegetrowsof{ file name or \loadedtable } to retrieve the total number of rows for some table programmatically. Some side-note: make sure that you terminate your code lines by '%' -- otherwise, TeX considers the newline character to be a whitespace and produces spurious white space in your table (or shifts the table). Here would be your code: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepackage{filecontents} \begin{filecontents*}{testdata.table} Val 2 1 3 \end{filecontents*} \pgfplotstableread{testdata.table}{\testdata} \pgfplotstablecreatecol[% create col/assign/.code={% \getthisrow{Val}\entry \ifnum\pgfplotstablerow>0 \pgfmathsetmacro{\entry}{max(\entry,\pgfmathaccuma)}% \fi \edef\pgfmathaccuma{\entry}%<--- CF : ATTENTION: do not forget '%' after lines otherwise TeX introduces spurious spaces \xdef\MAXVAL{\pgfmathaccuma}%<-- CF: this is a "dirty hack": simply write the result to some global variable - which can be used at any place in the file. \pgfkeyslet{/pgfplots/table/create col/next content}\entry }]{Max}\testdata \pgfplotstablecreatecol[% create col/assign/.code={% \getthisrow{Val}\entry \ifnum\pgfplotstablerow>0 \pgfmathsetmacro{\entry}{min(\entry,\pgfmathaccuma)}% \fi \edef\pgfmathaccuma{\entry} \pgfkeyslet{/pgfplots/table/create col/next content}\entry }]{Min}\testdata \pgfplotstablecreatecol[% create col/assign/.code={% \getthisrow{Val}\entry \ifnum\pgfplotstablerow>0 \pgfmathsetmacro{\entry}{add(\entry,\pgfmathaccuma)}% \fi \edef\pgfmathaccuma{\entry} \pgfkeyslet{/pgfplots/table/create col/next content}\entry }]{Sum}\testdata \pgfplotstablecreatecol[% create col/assign/.code={% \getthisrow{Sum}\entry \pgfmathsetmacro{\entry}{divide(\entry,\pgfplotstablerows)}% \pgfkeyslet{/pgfplots/table/create col/next content}\entry }]{Avg}\testdata \begin{document} \pgfplotstabletypeset[% every head row/.style={before row=\hline,after row=\hline}, every last row/.style={after row=\hline}, columns/Val/.style={fixed,fixed zerofill,precision=2}, columns/Min/.style={fixed,fixed zerofill,precision=2}, columns/Max/.style={fixed,fixed zerofill,precision=2}, columns/Avg/.style={fixed,fixed zerofill,precision=2}, columns/Sum/.style={fixed,fixed zerofill,precision=2}, ]{\testdata} % CF: dirty hack result: simply dereference global variable: The max value is \pgfmathprintnumber{\MAXVAL}. % CF: clean solution: get a single value of the table. \pgfplotstablegetelem{2}{Avg}\of\testdata The average value is \pgfmathprintnumber{\pgfplotsretval}. % CF: get number of rows, subtract by 1, and use that value: {% \pgfplotstablegetrowsof{\testdata}% \count0=\pgfplotsretval % means: store \pgfplotsretval into artihmetic TeX register \advance\count0 by-1 % subtract 1 from that register \edef\pgfplotsretval{\the\count0}% store result into \pgfplotsretval (as string) \pgfplotstablegetelem{\pgfplotsretval}{Sum}\of\testdata The sum is \pgfmathprintnumber{\pgfplotsretval}. }% this here restores \count0 to its previous value \end{document} Best regards Christian Am 23.03.2012 12:37, schrieb Martin Heller: > I would like to perform some simple calculations on columns of data that > I am importing from external files, typesetting with pgfplotstable, and > plotting with pgfplots. > > I can do the calculations using \pgfplotstablecreatecol but I can't > figure out how to report the result without typesetting the entire > column of intermediate calculations. In the example below I would like > to find the maximum, minimum, sum and average of the data in the Val > column and be able to use the results outside the table. In the example > the results are in the final row of the corresponding columns. > > Can I typeset the results outside the table with the tools provided by > pgfplots/pgfplotstable or are there an easier/better way to perform such > calculations once the data has been read with \pgfplotstableread? > > \documentclass{article} > \usepackage{tikz} > \usepackage{pgfplots} > \usepackage{pgfplotstable} > \pgfplotsset{compat=newest} > \usepackage{filecontents} > > \begin{filecontents*}{testdata.table} > Val > 2 > 1 > 3 > \end{filecontents*} > > \pgfplotstableread{testdata.table}{\testdata} > \pgfplotstablecreatecol[% > create col/assign/.code={% > \getthisrow{Val}\entry > \ifnum\pgfplotstablerow>0 > \pgfmathsetmacro{\entry}{max(\entry,\pgfmathaccuma)}% > \fi > \edef\pgfmathaccuma{\entry} > \pgfkeyslet{/pgfplots/table/create col/next content}\entry > }]{Max}\testdata > > \pgfplotstablecreatecol[% > create col/assign/.code={% > \getthisrow{Val}\entry > \ifnum\pgfplotstablerow>0 > \pgfmathsetmacro{\entry}{min(\entry,\pgfmathaccuma)}% > \fi > \edef\pgfmathaccuma{\entry} > \pgfkeyslet{/pgfplots/table/create col/next content}\entry > }]{Min}\testdata > > \pgfplotstablecreatecol[% > create col/assign/.code={% > \getthisrow{Val}\entry > \ifnum\pgfplotstablerow>0 > \pgfmathsetmacro{\entry}{add(\entry,\pgfmathaccuma)}% > \fi > \edef\pgfmathaccuma{\entry} > \pgfkeyslet{/pgfplots/table/create col/next content}\entry > }]{Sum}\testdata > > \pgfplotstablecreatecol[% > create col/assign/.code={% > \getthisrow{Sum}\entry > \pgfmathsetmacro{\entry}{divide(\entry,\pgfplotstablerows)}% > \pgfkeyslet{/pgfplots/table/create col/next content}\entry > }]{Avg}\testdata > > \begin{document} > > \pgfplotstabletypeset[% > every head row/.style={before row=\hline,after row=\hline}, > every last row/.style={after row=\hline}, > columns/Val/.style={fixed,fixed zerofill,precision=2}, > columns/Min/.style={fixed,fixed zerofill,precision=2}, > columns/Max/.style={fixed,fixed zerofill,precision=2}, > columns/Avg/.style={fixed,fixed zerofill,precision=2}, > columns/Sum/.style={fixed,fixed zerofill,precision=2}, > ]{\testdata} > > \end{document} > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Pgfplots-features mailing list > Pgfplots-features@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pgfplots-features ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features