I summed up a column in R Markdown and now I want to insert the sum at the end of the table.
Code for summing up:
sum_value<-sum(table$Col3)
I tried to add a row with dplyr to insert the sum but failed. Now I'm just put the sum at the bottom of the table.
It should look like:
Col1|Col2|Col3
A|B|111.10
A|C|2353.45
B|D|2364.53
Sum of Col3: 4829.08
Col3 are currencies.
Insert-value-code:
``{=tex}
\centering Sum of Col3: {`r as.double(sum_value)`}
``
But it looks like: 4.82908 x10^3
I tried to convert the value of Col3 into double, integer and character by using as.integer/double/character(sum_value)
at the moment I use the value in my PDF document, but that didn't work. Integer (of course) cut the decimals and double and character get the x10^n-output.
To multiple the sum with 100 didn't work either.
Thanks for recommendations.
Edit.
tex.-file:
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[margin=1in]{geometry}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}
\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight
else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\usepackage[utf8]{inputenc} \usepackage{longtable}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if
available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
hidelinks,
pdfcreator={LaTeX via pandoc}}
\author{}
\date{\vspace{-2.5em}}
\begin{document}
\textbf{H1}
\hfill \includegraphics[width=2.13542in,height=0.57292in]{PATH}
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\hypertarget{section}{%
\section{}\label{section}}
\hypertarget{section-1}{%
\section{}\label{section-1}}
\hypertarget{section-2}{%
\section{}\label{section-2}}
\centering\LARGE{H2}
\centering\LARGE{H2}
\centering\LARGE{Date1/Date2}
\centering\large(Date3)
\newpage
\listoftables
\newpage
\newpage
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1497}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3653}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.4072}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) *
real{0.0778}}@{}}
\caption{Recht}\tabularnewline
\toprule()
\begin{minipage}[b]{\linewidth}\centering
Sale Date
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Author
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Booktitle
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Price
\end{minipage} \\
\midrule()
\endfirsthead
\toprule()
\begin{minipage}[b]{\linewidth}\centering
Sale Date
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Author
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Booktitle
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Price
\end{minipage} \\
\midrule()
\endhead
13.09.2000 & NN, VN & Title1 & 189.1 \\
15.12.2000 & NN, VN & Title2 & 23.66 \\
18.03.2000 & NN, VN & Title3
Title & 19 \\
15.02.2000 & NN, VN & Title4
& 76.94 \\
14.02.2000 & NN, VN & Title5
Title & 90.38 \\
15.02.2000 & NN, VN & Title6 & 56.43 \\
15.02.2000 & NN, VN & Title7 &
16.41 \\
15.02.2000 & NN, VN & Title8 &
236.2 \\
09.05.2000 & NN, VN & Title9
& 40.92 \\
\bottomrule()
\end{longtable}
\centering Sum of Col4: {\ensuremath{12.12343534\times 10^{6}}}
\newpage
\end{document}
Ok, a year after my question was set, I got it by myself. I added following code:
```{r echo=FALSE}
options("scipen"=100, "digits"=6)
```
So the scientifical notation was gone for the whole document.