[R-pkg-devel] Encoding problem

David Scott d.scott at auckland.ac.nz
Sun Jan 29 13:40:52 CET 2017


I am trying to add a vignette to xtable showing how to incorporate some 
Chinese characters following an enquiry from a user.

I can create the vignette satisfactorily just processing the knitr file 
normally, with the resulting pdf displaying Chinese characters in the R 
code and also as headings when I produce a table. However when I try to 
build the package with the vignette included, I get:

* creating vignettes ...Warning: running command 
'"C:/PROGRA~1/R/R-33~1.2/bin/x64/Rscript" --vanilla
  ERROR
Error: Vignette 'ChineseCharacters.Rnw' is non-ASCII but has no declared 
encoding
Execution halted
make: *** [build] Error 1

I updated R to 3.3.2 and Rtools to 33 before running the build.

The vignette starts as follows:

%\VignetteIndexEntry{xtable Chinese Characters}
%\VignetteDepends{xtable}
%\VignetteKeywords{LaTeX, HTML, table}
%\VignettePackage{xtable}
% !Rnw weave = knitr
% \VignetteEngine{knitr::knitr}
%!\VignetteEncoding{UTF-8}
%**************************************************************************
\documentclass{ctexart}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{hyperref}
\usepackage{inputenx}

The section of the file which is not ASCII is:

<<preparedata>>=
### Prepare data
library(knitr)
library(xtable)

tbl <- data.frame(positivePairs = 0, negativePairs = 0,
                   avePositiveSpread = NA,
                   aveNegativeSpread = NA,
                   PnL = 435, sumPnL = 144358.7)
names(tbl) <- c("ÕýÏò¿ª²Ö", "¸ºÏò¿ª²Ö", "ÕýÏò¿ª²Öƽ¾ù¼Û²î",
                 "¸ºÏò¿ª²Öƽ¼Û¼Û²î", "µ±ÈÕËðÒæ", "ÀÛ¼ÆËðÒæ")
@

I am a bit of a novice at encodings, and know nothing about Chinese 
characters so any advice is welcome.

David Scott



-- 
_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Volunteer Arena Manager:
Orienteering Sprint Final at University of Auckland
World Masters Games 2017



More information about the R-package-devel mailing list