0

I was working on some categorical variables and created a contingency table using the following code:

mytable <- table(Gender, Income)

The output looks like below (which is not nice-looking):

  Work.Status
Gender   Employed Full-time Employed Part-time Unemployed
  Male                  433                 35         29
  Female                427                174        247

Is there any way that I can format this table to make it better looking (e.g. change the font, color, and size of the variables)? I tried a few methods from the web, but didn't get the desired results....

0

1 Answer 1

1

It isn't entirely clear from your question what you want to achieve. Is this an R to latex question or is it simply a formatting in latex question?

I favour the xtable package in R for taking tables in R to latex. A very quick example for categorical data below. The knitr package is also excellent for combining R with Latex output.

   library(xtable)
   data(tli)
   head(tli)
   table(tli$sex, tli$grade)
   print(xtable(table(tli$sex, tli$grade), booktabs = TRUE))

Which returns

% latex table generated in R 3.0.0 by xtable 1.7-1 package
% Thu Nov 28 09:00:24 2013
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrrr}
  \hline
 & 3 & 4 & 5 & 6 & 7 & 8 \\ 
  \hline
F &   6 &   9 &   8 &  11 &  10 &   7 \\ 
  M &   9 &   6 &   7 &  12 &   8 &   7 \\ 
   \hline
\end{tabular}
\end{table}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.