Table in Latex

Here reported the code for a simple table in \LaTeX:

\begin{table}[h]
  \begin{center}
    \begin{tabular}{|c|c|c|}
      \hline Rows  & Columns 1 & Column 2} \\
      \hline Row 1 & Value 1,1 & Value 2,1 \\
      \hline Row 2 & Value 1,2 & Value 2,2 \\
      \hline Row 3 & Value 1,3 & Value 2,3 \\
      \hline Row 4 & Value 1,4 & Value 2,4 \\ \hline
    \end{tabular}
    \caption[Short title for contains]{Description of table content}
    \label{label_of_choice}
  \end{center}
\end{table}

We the command \begin{tabular} we position the table within the the float environment table at which we add the position between [] (h, t, b, etc).

The command \begin{center} or the alternative \centering will position the table in the middle of the page.

\begin{tabular} starts the table itself. We can decide the number n of columns adding bars ‘|’ within the braces {}, to which has always to correspond a number of ‘&’ of n-1

The caption has to be insert between tabular and table.

Today over the internet are present many online tools for the creation of tables.
Such websites are quite handy, and it is easy to produce complex tables.

My favourite one is: tablesgenerator

Advertisements

Simple bar-plots using ggplot2

The package ggplot2 is one of the most powerful resource for plot making available in R.
Although, it has with quite a learning curve, that could be intimidating, it is definitely worth the effort.

In here I want to show a couple of the first bar plot I ever made with the ggplot2 package:

# For this plots we have the information regarding a database of mice
# immunised with two different antigens OVA and CFA,
# and put down at different time points post-immunisation.
# The Control group has time zero because those are not immunised 

library(ggplot2)
time_days=c(0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,7,7,7,7,7,14,14,14,14,14,14,60,60,60,60,60,60,60,60,60,60,60)
antigens=c('Control','Control','Control','Control','Control','Control','Control','Control','Control','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA','CFA','OVA','OVA','OVA','CFA','CFA')

db <- data.frame(time_days,antigens)  # Our database as data.framse

ggplot2::qplot(
 data = db,
 factor(time_days),
 fill = factor(time_days),
 geom = "bar"
 ) +
 ggplot2::theme_classic()+
 ggplot2::scale_fill_discrete(name='Time in days') +
 ggplot2::ggtitle('Group of mice per date of sacrifice') +
 ggplot2::xlab('Time in days') +
 ggplot2::ylab('Number of mice')

With the following result:

barplot1With this plot we see the number of mice and the time they have been put down.

Now if we want to see the number of mice and the antigens we could do the follow:

ggplot2::qplot(
data=db,
geom="bar",
factor(time_days),
fill=factor(antigens)
) +
ggplot2::theme_classic() +
ggplot2::ggtitle('Group of mice per date of sacrifice and antigens')+
ggplot2::scale_fill_discrete(name='Antigens') +
ggplot2::xlab('Time in days') +
ggplot2::ylab('Amount')

With the following result:

barplot2