You don't need datatool
, at least for this work. You can sort the data without showing scientific notation and make a beautiful table just inserting some R code in your LaTeX file and compile with Sweave
(or knitr
).
To do in this way, you LaTeX document must have a .Rnw
extension and compile in two steps with:
R CMD Sweave MWE.Rnw % this make MWE.tex
pdflatex MWE.tex % this make MWE.pdf
If you file have crossreferences, as usual, you must repeat the pdflatex compilation. If only a pdflatex run is needed, you can make all with R:
R CMD Sweave --pdf MWE.Rnw % this make the MWE.pdf
(Note: RStudio understand .Rnw
files and make all these steps with one click.)
This is the example: (the external data source is typed verbatim, you can copy this part and save as text.csv
to test the code):
\documentclass[spanish,11pt]{article}
\begin{document}
\setlength{\parindent}{0pt}
\SweaveOpts{concordance=TRUE}
Raw file \texttt{text.csv}:
\begin{verbatim}
minor, big
0.34552, 25
1.23e-4, 34
5.45677223344, 12
0.000001, 99
\end{verbatim}
R display in plain text by default
<<RawTable,echo=F>>=
a <- read.table("text.csv", header=TRUE, sep=",")
a
@
R display ordered and rounded:
<<RawTable,echo=F>>=
round(a[order(a$minor), ],4)
@
In R also but with \LaTeX{} style
<<Mytable,echo=F,results=tex>>=
library(xtable)
xtable(a[order(a$minor), ], caption="My ordered table",digits=4)
@
\end{document}

Sweave
andxtable
in R?