On Mon, 25 Aug 2008, Christoph Heibl wrote:
Dear list,
I am trying to replace Unicode notation of German and Spanish special
characters (as read in by read.csv from excel spreadsheets) by character
strings that can be interpreted by LaTeX.
Why? LaTeX can read UTF-8 if you tell it to.
E.g.:
uni2latex <- function(x){
x <- gsub("&", "et", x, fixed = TRUE)
# Deutsch
x <- gsub("\u0080", "\\\"A", x, fixed = TRUE)
x <- gsub("\u008a", "\\\"a", x, fixed = TRUE)
x <- gsub("\u0085", "\\\"O", x, fixed = TRUE)
x <- gsub("\u009a", "\\\"o", x, fixed = TRUE)
x <- gsub("\u0086", "\\\"U", x, fixed = TRUE)
x <- gsub("\u009f", "\\\"u", x, fixed = TRUE)
x <- gsub("§", "\\ss{}", x, fixed = TRUE)
# Español
x <- gsub("\u0084", "\\~N", x, fixed = TRUE)
x <- gsub("\u0096", "\\~n", x, fixed = TRUE)
x <- gsub("ç", "\\\'A", x, fixed = TRUE)
x <- gsub("\u0087", "\\\'a", x, fixed = TRUE)
x <- gsub("\u0083", "\\\'E", x, fixed = TRUE)
x <- gsub("\u008e", "\\\'e", x, fixed = TRUE)
x <- gsub("ę", "\\\'I", x, fixed = TRUE)
x <- gsub("\u0092", "\\\'i", x, fixed = TRUE)
x <- gsub("î", "\\\'O", x, fixed = TRUE)
x <- gsub("\u0097", "\\\'o", x, fixed = TRUE)
x <- gsub("ň", "\\\'U", x, fixed = TRUE)
x <- gsub("\u009c", "\\\'u", x, fixed = TRUE)
x
}
This function works fine for me if I source from a file, but if I try to
include it into a package, the package cannot be installed:
"Error in parse(n = -1, file = file) : invalid \uxxxx sequence (line 835)"
And which line is that?
(1) Why is there a difference between sourcing and package installation?
Quite possibly. What locale are you using to install the package? Mac OS
X terminals seem to default to C.
(2) How can I fix this?
Set a proper locale.
(3) Perhaps there is a more reasonable way for doing this?
Yes, fix it in LaTeX.
I am using R_2.7.1.
But the following is not the output from sessionInfo() as requested in the
posting guide.
Hardware:
Model Name: MacBook
Model Identifier: MacBook2,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.16 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per processor): 4 MB
Memory: 3 GB
Bus Speed: 667 MHz
Boot ROM Version: MB21.00A5.B07
SMC Version: 1.17f0
Serial Number: W87187FAYA4
Sudden Motion Sensor:
State: Enabled
________________________________________________________
Christoph Heibl
Systematic Botany
Ludwig-Maximilians-Universität München
Menzinger Str. 67
D-80638 München
GERMANY
phone: +49-(0)89-17861-251
e-mail: [EMAIL PROTECTED]
http://www.christophheibl.de/ch-home.html
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.