Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

printTable

'Nice' table format.


Description

This functions prints a table on the console in a 'nice' format.

Usage

printTable(obj, row.names = TRUE, justify = 'right')

Arguments

obj

an object of class 'data.frame' or 'matrix'. It must be at least two columns, the first columns is considered as the 'row.names' and is left justified (if the 'row.names' argument is set to TRUE), while the rest of the columns are right justified.

row.names

logical indicating whether the first column or variable is treated as a 'row.names' column and must be left-justified. Default value is TRUE.

justify

character as 'justify' argument from format function. It applies to all columns of the data.frame or matrix when 'row.names' argument is FALSE or all columns excluding the first one otherwise. Default value is 'right'.

Value

No object is returned.

Note

This function may be usefull when printing a table with some results with variables as the first column and a header. It adds 'nice' lines to highlight the header and also the bottom of the table.

It has been used to print 'compareSNPs' objects.

See Also

Examples

require(compareGroups)

data(regicor)

# example of the coefficients table from a linear regression
model <- lm(chol ~ age + sex + bmi, regicor)
results <- coef(summary(model))
results <- cbind(Var = rownames(results), round(results, 4))
printTable(results)

# or visualize the first rows of the iris data frame. 
# In this example, the first column is not treated as a row.names column and it is right justified.
printTable(head(iris), FALSE)

# the same example with columns centered
printTable(head(iris), FALSE, 'centre')

compareGroups

Descriptive Analysis by Groups

v4.5.1
GPL (>= 2)
Authors
Isaac Subirana [aut, cre] (<https://orcid.org/0000-0003-1676-0197>), Joan Salvador [ctb]
Initial release
2021-03-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.