Skip to content
Prev 168299 / 398502 Next

Sweave'ing Danish characters

Hi,

I am writing an Sweave document and am using 'xtable' to make frequency tables of diagnoses of people undergoing cholecystectomy. Some of these diagnoses contain Danish characters ("?", "?", and "?"), and these characters are all garbled in the Latex document after I run Sweave. The odd thing is, everything looks absolutely right in the R console, and if I enter the same Danish characters in a new variable, the new variable produces no problems?! Therefore, I cannot offer a reproducible example, but I am hoping nonetheless that someone can point me towards a solution.

To illustrate:
% latex table generated in R 2.8.1 by xtable 1.5-4 package
% Mon Jan 26 23:31:37 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
  \hline
 & test2 \\
  \hline
Kr?ft i ford?jelsessystemet &   1 \\	# It looks right here, but in the .tex-file it says "Kr??ft i ford??jelsessystemet"
   \hline
\end{tabular}
\end{center}
\end{table}
% latex table generated in R 2.8.1 by xtable 1.5-4 package
% Mon Jan 26 23:36:53 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
  \hline
 & V1 \\
  \hline
Kr?ft i ford?jelsessystemet &   1 \\	# See, no problems here!
   \hline
\end{tabular}
\end{center}
\end{table}


I am using Windows Vista 64-bit and MikTex 2.7. 

Best regards,
Peter.
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Hmisc_3.4-4    foreign_0.8-30 xtable_1.5-4  

loaded via a namespace (and not attached):
[1] cluster_1.11.12 grid_2.8.1      lattice_0.17-20 tools_2.8.1