yCalleecharan yCalleecharan -3 years ago 97
R Question

The use of format.pval in R (and with \Sexpr in Sweave)

I have read the help file for

and was wondering if this is a right tool to output numbers with proper format as far as significant digits are concerned

In this post:

R / Sweave formatting numbers with \Sexpr{} in scientific notation

a solution was proposed and I wonder if the function
is already here to do this.

And I guess that we can just use it in Sweave as
\Sexpr{format.pval(a value/variable here)}
together with options for the number of significant digits.

Thanks a lot...

Answer Source

format.pval is specifically designed to format printed p.values, for example when viewing the output of lm.

The workhorse for format.pval is format which is more general in purpose. So you should probably use format or its cousins - prettyNum and formatC instead.

Footnote: for formatting dates (POSIXct or POSIXlt) you need the date formatting function strptime

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download