The question was asked with pdf as the output, here is an answer using knitr, and something more appropriate than just \includegraphics

The trick is to use the adjustbox package in latex, with the following arguments:
- the
height (later used as the argument to the R function get_picture_code) is the height of the picture. - the
valign argument (which default here to valign=m), will perform vertical adjustment according to the text, - the
margin here defined as 1ex surrounding the picture allows to separate the flags.
So we just use this function
get_picture_code <- function(path,height,col=NULL) { paste0("\\adjustimage{height=",height,",valign=m,margin*=1ex}{",path,"}") }
To get a vector of images added to the table.
Finally we use xtable with argument sanitize.text.function = identity to print the tex code :
\documentclass{article} \usepackage{adjustbox} \begin{document} <<load_libraries, echo = FALSE, eval = TRUE, results ="hide">>= library(knitr) library(xtable) @ <<include_images, echo = FALSE, eval = TRUE, results ="hide">>= get_picture_code <- function(path,height,col=NULL){ paste0("\\adjustimage{height=",height,",valign=m,margin*=1ex}{",path,"}") } @ <<test, echo = FALSE, eval = TRUE, results ="hide">>= dat <- data.frame(country = c("Belgium", "Germany", "Holland", "Ireland"), Var1 = 1:4, Var2 = 11:14) mypath <- paste0("images/",dat$country,".png") dat$flag <- get_picture_code(path=mypath,height="0.8cm") dat$test <-NA dat$test[2:3] <-get_picture_code(path="images/orange_flag",height="0.6cm") print(xtable(dat, align = c("l","l","l","l","c","c"), caption = "Example with flags"), sanitize.text.function = identity, file="table_with_images.tex") @ \input{table_with_images.tex} \end{document}
The adjustbox documentation contains many other options, including background colors, trim, horizonal alignment which will allow you to do some very fine adjustment of the position of the images... There is also a nice example of the use of this package in TeX-Latex stackexchange