[Tex/LaTex] knitr: less/greater than sign displayed as (¡) and (¿)

knitrr

I'm a beginner in using knitr to generate a report. I have a R script (see below for an example; BTW I'm using RStudio for all of this) that runs without error and the output is a data frame. My rnw.file looks like this:

% !Rnw weave = knitr
\documentclass[a4paper]{article}
\begin{document}
<<echo=FALSE,message=FALSE>>=
source("test.R")
kable(test.mat)
@
\end{document}

which displays the table quite nicely. The only problem I have is with the ">" (greater than) sign in the last column which is shown as "¿".

In found something about using

\usepackage[T1]{fontenc}

but this doesn't seem to do the trick here. Having included this, I can start compiling the script but after 10 minutes or so (and w/o it only took me some seconds to compile) I run into an error (exit code: 1).

Also, $>$ will not work for me here, and is displayed as $¿$ in the pdf.
I've already asked this question here w/o getting a elegant solution so far.

Thanks in advance!

R.script (saved as "test.R"):

temp <- 12
test.mat <- as.data.frame(matrix(NA,ncol=2,nrow=1))
test.mat$V1 <- 2
test.mat$V2 <- paste(temp,"subjects > 28 days",sep=" ")

Best Answer

I can't explain why it is working now, but here is what I found I should use in the preambel:

\usepackage{lmodern}
\usepackage[T1]{fontenc}

Found this in another thread (not really related to my question), but now I get what I want in the R output (no changes required in the R.script) as well as in the pdf.