Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to load data into somes tables using pgfplotstable. My problem is that the data in the files is in a bit of a different format than the way I want to present it in the table, and after I transform it, is "missing" some row data. After scouring the internet I've not been able to come up with something that works, so here I am!

I'm not great at describing it, so I will just show you an example. I want this:

Desired output showing correct row values for the r_lesion column

But so far I can only do this:

Current output showing NaN row values for the r_lesion column

The code I used to create this short demo is as follows (all the "pgfplotstableread" would be replaced by loading the same data from files using "pgfplotstabletranspose"):

\documentclass{article}

\usepackage{booktabs}
\usepackage{pgfplotstable}

\begin{document}

\pgfkeys{/pgf/number format/.cd,fixed,precision=2}

\pgfplotstableset{%
    every head row/.style={
        before row={%
            \toprule
            \ensuremath{r_{lesion}} & \multicolumn{4}{c}{\ensuremath{E_{nom}}} \\
        },
        after row=\midrule
    },
    every last row/.style={after row=\bottomrule}
}

\pgfplotstabletypeset[
    numeric type,
    columns/(mm)/.style={
        column type=r
    }
]{
    (mm)  0.32 0.56 1.80 3.20
    5  0.98 1.03 1.26 1.47
    10 0.84 0.95 1.44 1.74
    15 0.05 0.65 1.86 2.57
    20 0.03 0.52 2.13 3.19
}

\vspace{0.5in}

\pgfplotstableread{
    sr   esr
    0.32 0.98
    0.56 1.03
    1.8  1.26
    3.2  1.47
}\rowA

\pgfplotstableread{
    sr   esr
    0.32 0.84
    0.56 0.95
    1.8  1.44
    3.2  1.74
}\rowB

\pgfplotstableread{
    sr   esr
    0.32 0.05
    0.56 0.65
    1.8  1.86
    3.2  2.57
}\rowC

\pgfplotstableread{
    sr   esr
    0.32 0.03
    0.56 0.52
    1.8  2.13
    3.2  3.19
}\rowD

\pgfplotstabletranspose[columns=esr, numeric type]{\transA}{\rowA}
\pgfplotstabletranspose[columns=esr, numeric type]{\transB}{\rowB}
\pgfplotstabletranspose[columns=esr, numeric type]{\transC}{\rowC}
\pgfplotstabletranspose[columns=esr, numeric type]{\transD}{\rowD}
\pgfplotstablevertcat{\renderedTable}{\transA}
\pgfplotstablevertcat{\renderedTable}{\transB}
\pgfplotstablevertcat{\renderedTable}{\transC}
\pgfplotstablevertcat{\renderedTable}{\transD}
\pgfplotstabletypeset[
    columns/colnames/.style={
        numeric type,
        column name={(mm)},
        column type=r
    },
    columns/0/.style={
        column name={0.32}
    },
    columns/1/.style={
        column name={0.56}
    },
    columns/2/.style={
        column name={1.80}
    },
    columns/3/.style={
        column name={3.20}
    }
]\renderedTable

\end{document}

If I change the "colnames" back to a string type, it shows "esr" instead of "NaN", but I still want to be able to manually input those values in the document, so that I could do something like:

\defineColumnOneRows{5,10,20,25}

And get those values into the rows of the first column.

Any help you can offer is incredibly appreciated! Thanks for taking a look!

share|improve this question
    
Are you sure NaN (Not A Number) isn't from the original? This is typically generated on a divide by zero. –  John Kormylo May 5 at 14:58
    
Yes.. the NaN is due to the "numeric type" style applied to the colnames column. If I turn that into "string type", it places "esr" (the column name in the "files") as the row entries (instead of NaN). I need those row entries to be manually definable, since the data that needs to go there isn't in my files. –  FuzzyWuzzie May 5 at 15:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.