dc {cwhstring}R Documentation

Convert number for use in decimal dot centered table columns

Description

Replace "." in a number by "&" for LaTeX tables using column specification r@{.}l

Usage

  dc (x,d,ch="&")
  dcn(x,d,ch="&")

Arguments

x Numerical vector.
d If not missing, determines number of decimals after ".". d >= 0
ch Substitute "." by ch

Value

string representation of x suitable for table column centered on "."

Warning

d missing is an error. dcn(x,0) does not serve its intended purpose, see examples!

Note

dc and dcn produce identical results for d > 0, but not for d <= 0 , see \examples.

Author(s)

Christian W. Hoffmann, christian.hoffmann@wsl.ch,
http://www.wsl.ch/staff/christian.hoffmann

Examples

  dc (c(0,pi,2*pi,-30*pi),3)   # "0&0"     "3&142"   "6&283"   "-94&248"
  dcn(c(0,pi,2*pi,-30*pi),3)   # "0&000"   "3&142"   "6&283"   "-94&248"
#  d = 0:
  dc (c(0,pi,2*pi,-30*pi),0)   # "0&0"  "3&0"  "6&0"  "-94&0"
  dcn(c(0,pi,2*pi,-30*pi),0)   # "0"    "3"    "6"    "-94",  beware !
#  d < 0:
  dc (c(0,pi,2*pi,-30*pi),-3)  # "0&0"    "3&0"    "6&0"    "-94&0"
  dcn(c(0,pi,2*pi,-30*pi),-3)  # "0&000"  "3&142"  "6&283"  "-94&248"

[Package cwhstring version 1.0.3 Index]