Description Usage Arguments Value Author(s) See Also Examples

View source: R/print.CatTable.R

`print`

method for the `CatTable`

class objects created by `CreateCatTable`

function.

1 2 3 4 5 6 |

`x` |
Object returned by |

`digits` |
Number of digits to print in the table. |

`pDigits` |
Number of digits to print for p-values (also used for standardized mean differences). |

`quote` |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily. |

`missing` |
Whether to show missing data information. |

`explain` |
Whether to add explanation to the variable names, i.e., (%) is added to the variable names when percentage is shown. |

`printToggle` |
Whether to print the output. If FLASE, no output is created, and a matrix is invisibly returned. |

`noSpaces` |
Whether to remove spaces added for alignment. Use this option if you prefer to align numbers yourself in other software. |

`format` |
The default is "fp" frequency (percentage). You can also choose from "f" frequency only, "p" percentage only, and "pf" percentage (frequency). |

`showAllLevels` |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information. |

`cramVars` |
A character vector to specify the two-level categorical variables, for which both levels should be shown in one row. |

`test` |
Whether to show p-values. TRUE by default. If FALSE, only the numerical summaries are shown. |

`exact` |
A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test). |

`smd` |
Whether to show standardized mean differences. FALSE by default. If there are more than one contrasts, the average of all possible standardized mean differences is shown. For individual contrasts, use |

`CrossTable` |
Whether to show the cross table objects held internally using gmodels::CrossTable function. This will give an output similar to the PROC FREQ in SAS. |

`...` |
For compatibility with generic. Ignored. |

A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via `write.csv`

.

Kazuki Yoshida

`CreateTableOne`

, `CreateCatTable`

, `summary.CatTable`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ```
## Load
library(tableone)
## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
data(pbc)
## Check variables
head(pbc)
## Create an overall table for categorical variables
catVars <- c("status","ascites","hepato","spiders","edema","stage")
catTableOverall <- CreateCatTable(vars = catVars, data = pbc)
## Simply typing the object name will invoke the print.CatTable method,
## which will show the sample size, frequencies and percentages.
## For 2-level variables, only the higher level is shown for simplicity.
catTableOverall
## If you need to show both levels for some 2-level factors, use cramVars
print(catTableOverall, cramVars = "hepato")
## Use the showAllLevels argument to see all levels for all variables.
print(catTableOverall, showAllLevels = TRUE)
## You can choose form frequencies ("f") and/or percentages ("p") or both.
## "fp" frequency (percentage) is the default. Row names change accordingly.
print(catTableOverall, format = "f")
print(catTableOverall, format = "p")
## To further examine the variables, use the summary.CatTable method,
## which will show more details.
summary(catTableOverall)
## The table can be stratified by one or more variables
catTableBySexTrt <- CreateCatTable(vars = catVars,
strata = c("sex","trt"), data = pbc)
## print now includes p-values which are by default calculated by chisq.test.
## It is formatted at the decimal place specified by the pDigits argument
## (3 by default). It does <0.001 for you.
catTableBySexTrt
## The exact argument toggles the p-values to the exact test result from
## fisher.test. It will show which ones are from exact tests.
print(catTableBySexTrt, exact = "ascites")
## summary now includes both types of p-values
summary(catTableBySexTrt)
## If your work flow includes copying to Excel and Word when writing manuscripts,
## you may benefit from the quote argument. This will quote everything so that
## Excel does not mess up the cells.
print(catTableBySexTrt, exact = "ascites", quote = TRUE)
## If you want to center-align values in Word, use noSpaces option.
print(catTableBySexTrt, exact = "ascites", quote = TRUE, noSpaces = TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.