Learn R Programming

bruceR (version 0.7.2)

print_table: Print a three-line table (to R Console or MS Word).

Description

This basic function prints any data frame as a three-line table to either R Console or Microsoft Word (.doc). It has been used in many other functions in bruceR. The implementation of Word output is using HTML code. You can check the raw HTML code by opening the Word file with any text editor. See here for a list of other functions in bruceR that support Word output.

Usage

print_table(
  x,
  digits = 3,
  nsmalls = digits,
  row.names = TRUE,
  col.names = TRUE,
  title = "",
  note = "",
  append = "",
  line = TRUE,
  file = NULL,
  file.align.head = "auto",
  file.align.text = "auto"
)

Arguments

x

Matrix, data.frame (or data.table), or any model object (e.g., lm, glm, lmer, glmer, ...).

digits, nsmalls

Numeric vector specifying the number of decimal places of output. Default is 3.

row.names, col.names

Print row/column names. Default is TRUE (column names are always printed). To modify the names, you can use a character vector with the same length as the raw names.

title

Title text, which will be inserted in <p></p> (HTML code).

note

Note text, which will be inserted in <p></p> (HTML code).

append

Other contents, which will be appended in the end (HTML code).

line

Lines looks like true line (TRUE) or === --- === (FALSE).

file

File name of MS Word (.doc).

file.align.head, file.align.text

Alignment of table head or table text: "left", "right", "center". Either one value of them OR a character vector of mixed values with the same length as the table columns. Default alignment (if set as "auto"): left, right, right, ..., right.

Value

Invisibly return a list of data frame and HTML code.

See Also

Describe, Freq, Corr

Examples

Run this code
# NOT RUN {
print_table(airquality, file="airquality.doc")
unlink("airquality.doc")  # delete file for test

model=lm(Temp ~ Month + Day + Wind + Solar.R, data=airquality)
print_table(model)
print_table(model, file="model.doc")
unlink("model.doc")  # delete file for test

# }

Run the code above in your browser using DataLab