TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how do I change each 0.0 to -- without having to reference each as string type or making the whole table string type? The actual table is quite long and it would take too long to do it manually. For the same reason there would be a marked improvement in readability if the table wasn't cluttered up with lots of zeros.

The final table should look something like

Flow            Bibble         Bobble        Gumph
Extant             1              2             3
Intant             --             4             5
My sainted aunt    --             6             7

using for example the MWE below,

\pgfplotstabletypeset[columns/Flow/.style={string type,column type={l}},ignore chars={\^^M},col sep=&,row sep=\\]{
                  Flow,   Bibble ,   Bobble ,   Gumph
                Extant,    1,           2,      3
                Intant,    0.0 ,        4,      5
       My sainted aunt,    0.0,         6,      7),header=F,sep=",")
share|improve this question
Here is one pretty obvious solution, but I'm not sure its the right one. Would be open to deleting this query if its self-evident. Any comments appreciated... if I put the replacement string replace in math-mode it does the trick. so ...,string replace*={0.0}{$-$}, gives me the result I need. – Tahnoon Pasha Nov 22 '12 at 1:45
The use of string replace sounds like the most simple solution. An alternative would be to write some TeX code which is simular to the clear infinite style (by copy-pasting from the source code). But that is clearly much more involved. – Christian Feuersänger Nov 22 '12 at 19:52
up vote 4 down vote accepted

I don't know if this applies to knitr, but other general cases can be handled by first emptying the @cell content for unwanted entries and then post processing the empty cells with the desired result. Another example can be found in Adjusting command behavior based on argument type

\pgfplotsset{compat=1.8,%supress warnings
     table/zero to dash/.style={
        preproc cell content/.code={%
             \pgfkeysgetvalue{/pgfplots/table/@unprocessed cell content}\pgfmathresult%
             \ifnum\pgfmathresult>0\pgfkeyssetvalue{/pgfplots/table/@cell content}{}\fi
        empty cells with={--}% If empty place --

\pgfplotstabletypeset[columns={Flow,Bibble,Bobble,Gumph},% declare column names
columns/Flow/.style={string type,column type={l}},
    zero to dash,
col sep=comma
Flow,          Bibble,  Bobble, Gumph
Extant,            1 ,       2,      3
Intant,          0.0 ,       4,      5
My sainted aunt, 0.0 ,       6,      7

enter image description here

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.