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.

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)"

(1) Why is there a difference between sourcing and package installation?
(2) How can I fix this?
(3) Perhaps there is a more reasonable way for doing this?


I am using R_2.7.1.

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.

Reply via email to