[R] write.csv covert Åland to <c5>land

John Kane jrkr|de@u @end|ng |rom gm@||@com
Tue Oct 20 15:56:47 CEST 2020


It looks like an encoding problem.

It works fine for me with R encoding set to UTF-8

Here is part of my sessionInfo() results
[1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8

I would suggest issuing the command
sessionInfo()
and seeing what your encoding is.



On Tue, 20 Oct 2020 at 08:22, Jinsong Zhao <jszhao using yeah.net> wrote:

> Hi there,
>
> Why the same string is displayed in different form?
>
>  > abc[,1]
> [1] "Åland"       "Afghanistan"
>  > abc
>           name
> 1    <c5>land
> 2 Afghanistan
>
> And more...
>
>  > dput(abc, "aa.txt")
>  > dget("aa.txt")
>           name
> 1    <c5>land
> 2 Afghanistan
>  > dget("aa.txt")[,1]
> [1] "<c5>land"    "Afghanistan"
>
> Best,
> Jinsong
>
> On 2020/10/20 17:13, Jinsong Zhao wrote:
> > Hi there,
> >
> > I tried to export the names of country to a csv file with write.csv().
> > In the resulted file, Åland was coverted to <c5>land. Is there any way
> > could prevent this happening? Thanks!
> >
> >  > abc
> > [1] "Åland"
> >  > write.table(abc, file = "")
> > "x"
> > "1" "<c5>land"
> >
> > Best,
> > Jinsong
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>


-- 
John Kane
Kingston ON Canada

	[[alternative HTML version deleted]]



More information about the R-help mailing list