[R] Encoding

Duncan Murdoch murdoch.duncan at gmail.com
Sun Oct 28 12:05:36 CET 2012


On 12-10-28 3:49 AM, Eva Prieto Castro wrote:
> Hi again, Duncan:
>
> I understand you tell me, but I don't reach it runs in Mac. How must I do?.

There is a function in the tools package called showNonASCIIfile.  If 
you run it on each source file in your package, you may detect other 
non-ASCII characters besides the degree symbol.

Duncan Murdoch

>
> Thanks.
>
> Eva
>
> --- El *sáb, 27/10/12, Duncan Murdoch /<murdoch.duncan at gmail.com>/*
> escribió:
>
>
>     De: Duncan Murdoch <murdoch.duncan at gmail.com>
>     Asunto: Re: [R] Encoding
>     Para: "Eva Prieto Castro" <evapcastro at yahoo.es>
>     CC: r-help at r-project.org
>     Fecha: sábado, 27 de octubre, 2012 14:12
>
>     On 12-10-27 7:28 AM, Eva Prieto Castro wrote:
>      > Hi again:
>      >
>      > I could make tha package (in Windows 7) but it does not run in Mac.
>      >
>      > Please could you tell me how to make a package in Windows PC with
>     source code saved in utf-8 in the way the package runs on a Mac ?
>
>     One likely problem is that you need to declare in the DESCRIPTION file
>     which encoding you are using.  The other problem is that you may not be
>     consistently using UTF-8 encodings.  Since your system (as shown below)
>     defaults to Latin1, files produced by R will default to Latin1
>     encoding.
>        If you consistently use Latin1 and declare that in the DESCRIPTION,
>     your Mac should be able to work with the package.
>
>     In your other message you mentioned Unicode and UCS-2.  UCS-2 is not
>     UTF-8, they are different.  "Unicode" is ambiguous, but on Windows it
>     generally means UCS-2.  As you found, R can read that, but it's not
>     used
>     by default, so I would avoid it.
>
>     One other approach to this is to avoid non-ASCII characters.  Then
>     UTF-8
>     and Latin1 are the same, and you won't run into problems.  But if you
>     are writing Spanish, that's not easy.
>
>     Duncan Murdoch
>
>      >
>      > In my pc (where I create the package) :
>      >> l10n_info()
>      > $MBCS
>      > [1] FALSE
>      >
>      > $`UTF-8`
>      > [1] FALSE
>      >
>      > $`Latin-1`
>      > [1] TRUE
>      >
>      > $codepage
>      > [1] 1252
>      >
>      >
>      > Thanks.
>      >
>      > Eva
>      >
>      > --- El sáb, 27/10/12, Eva Prieto Castro <evapcastro at yahoo.es
>     </mc/compose?to=evapcastro at yahoo.es>> escribió:
>      >
>      > De: Eva Prieto Castro <evapcastro at yahoo.es
>     </mc/compose?to=evapcastro at yahoo.es>>
>      > Asunto: Re: Encoding
>      > Para: r-help at r-project.org </mc/compose?to=r-help at r-project.org>
>      > Fecha: sábado, 27 de octubre, 2012 08:48
>      >
>      > Hi,
>      >
>      > I solved the problem as follows:
>      >
>      > source(file="example.R", encoding="UCS-2")
>      >
>      > Thanks
>      >
>      > Eva
>      >
>      > --- El sáb, 27/10/12, Eva Prieto Castro <evapcastro at yahoo.es
>     </mc/compose?to=evapcastro at yahoo.es>> escribió:
>      >
>      > De: Eva Prieto Castro <evapcastro at yahoo.es
>     </mc/compose?to=evapcastro at yahoo.es>>
>      > Asunto: Encoding
>      > Para: r-help at r-project.org </mc/compose?to=r-help at r-project.org>
>      > Fecha: sábado, 27 de octubre, 2012 07:34
>      >
>      > Hi,
>      >
>      > I work with R on Windows, so I use ANSI encode; but when I run my
>     projects on a linux or mac pc, It fails, so I change the encoding to
>     unicode (in the same mac pc) and runs ok.
>      >
>      > The problema is that I need tu make the package in mi pc
>     (windows) and when I
>      >   save my sources as unicode it fails: I make source("mydile.R")
>     and it return tle following:
>      >
>      > Error en eval(expr, envir, enclos) : objeto 'ÿþ' no encontrado
>      >
>      > How can I resolve it?. I need to make the package in a windows pc
>     ant it may run ok on all the OS.
>      >
>      > Thanks in advance.
>      >
>      > Eva
>      >
>      >     [[alternative HTML version deleted]]
>      >
>      >
>      >
>      > ______________________________________________
>      > R-help at r-project.org </mc/compose?to=R-help at 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.
>      >
>




More information about the R-help mailing list