lucid {lucid}R Documentation

Lucid printing

Description

Format a column of numbers in a way to make it easy to understand.

Usage

lucid(x, dig = 3, na.value = NULL, ...)

## Default S3 method:
lucid(x, dig = 3, na.value = NULL, ...)

## S3 method for class 'numeric'
lucid(x, dig = 3, na.value = NULL, ...)

## S3 method for class 'data.frame'
lucid(x, dig = 3, na.value = NULL, ...)

## S3 method for class 'matrix'
lucid(x, dig = 3, na.value = NULL, ...)

## S3 method for class 'list'
lucid(x, dig = 3, na.value = NULL, ...)

## S3 method for class 'tbl_df'
lucid(x, dig = 3, na.value = NULL, ...)

Arguments

x

Object to format.

dig

Number of significant digits to use in printing.

na.value

Character string to use instead of 'NA' for numeric missing values. Default is NULL, which does nothing.

...

Additional arguments passed to the data.frame method.

Details

Output from R is often in scientific notation, which makes it difficult to quickly glance at numbers and gain an understanding of the relative values. This function formats the numbers in a way that makes interpretation of the numbers _immediately_ apparent.

The sequence of steps in formatting the output is: (1) zap to zero (2) use significant digits (3) drop trailing zeros after decimal (4) align decimals.

Value

Text, formatted in a human-readable way. Standard R methods are used to print the value.

See Also

signif

Examples


x0 <- c(123, 12.3, 1.23, .123456) # From Finney, page 352
print(x0)
lucid(x0, dig=2)

x1 <- c(123, NA, 1.23, NA)
lucid(x1, na.value="--")

signif(mtcars[15:20,])
lucid(mtcars[15:20,])

x2 <- c(1/3, 5/3, 1, 1.5, 2, 11/6, 5/6, 8.43215652105343e-17)
print(x2)
lucid(x2)

# Which coef is 0 ? How large is the intercept?
df1 <- data.frame(effect=c(-13.5, 4.5,  24.5, 6.927792e-14, -1.75,
                    16.5, 113.5000))
rownames(df1) <- c("A","B","C","C1","C2","D","(Intercept)")
print(df1)
lucid(df1)

df2 <- data.frame(effect=c("hyb","region","region:loc","hyb:region",
                           "yr","hyb:yr","region:yr","R!variance"),
                  component=c(10.9,277,493,1.30E-04,126,22.3,481,268),
                  std.error=c(4.40,166,26.1,1.58E-06,119,4.50,108,3.25),
                  z.ratio=c(2.471,1.669,18.899,82.242,
                  1.060,4.951,4.442,82.242),
                  constraint=c("pos","pos","pos","bnd",
                  "pos","pos","pos","pos"))
print(df2)
lucid(df2)


[Package lucid version 1.8 Index]