[R] Chinese Garbled
William Dunlap
wdunlap at tibco.com
Tue Dec 17 00:09:33 CET 2013
>> columns are "处理水平",“组别”,"物种数"。 But when I read this file with function
>> "read.csv" and displayed, these Chinese characters are garbled like the
>> followings:
>>> x<-read.csv("richness.csv")
>>> x[1:5,]
>> X..理?? X.?? 物种数
>> 1 CK 总 34
You have to, at least, use the check.names=FALSE argument to read.csv.
E.g.,
> str(read.csv(text="%*,&*,$\n1,2,4\n2,3,5"))
'data.frame': 2 obs. of 3 variables:
$ X.. : int 1 2
$ X...1: int 2 3
$ X. : int 4 5
> str(read.csv(text="%*,&*,$\n1,2,4\n2,3,5", check.names=FALSE))
'data.frame': 2 obs. of 3 variables:
$ %*: int 1 2
$ &*: int 2 3
$ $ : int 4 5
There may be more you have to do.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of yuanzhi
> Sent: Monday, December 16, 2013 2:08 PM
> To: r-help at r-project.org
> Subject: Re: [R] Chinese Garbled
>
> Ista Zahn wrote
> > This is the R-help mailing list. If your problem persists when using R
> > from the command line or with the GUI shipped with R on your
> > (unspecified) platform post back here. Otherwise the RStudio support
> > forum is at https://support.rstudio.com
> >
> > Best,
> > Ista
> >
> > On Sat, Dec 14, 2013 at 12:22 AM, yuanzhi <
>
> > yuanzhi.li@
>
> > > wrote:
> >> Hello, I met a problem which needs your help. I reinstalled the R and
> >> Rstudio
> >> recently. After that, I found there was a problem that the Chinese
> >> character
> >> was garbled in Rstudio sometimes.
> >>
> >> example 1
> >> "richness.csv" is a file containing three columns and the names of the
> >> three
> >> columns are "处理水平",“组别”,"物种数"。 But when I read this file with
> function
> >> "read.csv" and displayed, these Chinese characters are garbled like the
> >> followings:
> >>> x<-read.csv("richness.csv")
> >>> x[1:5,]
> >> X..理?? X.?? 物种数
> >> 1 CK 总 34
> >> 2 CK 总 43
> >> 3 CK 总 45
> >> 4 CK 总 41
> >> 5 CK 总 33
> >>
> >> example2
> >>
> >> Sometimes the prompting message also contains garabled Chinese
> >> characters.
> >> For example, when I run "?bargraph.CI"(which is a function in package
> >> "sciplot") before I use the cammand "library(sciplot)", it will appear
> >> the
> >> following message with garbled Chinese characters:
> >>> ?bargraph.CI
> >> No documentation for 慴argraph.CI?in specified packages and libraries:
> >> you could try ??bargraph.CI?
> >>
> >> So, what can I do to solve the problem. Thank you!
> >> Yuanzhi
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >> http://r.789695.n4.nabble.com/Chinese-Garbled-tp4682184.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> ______________________________________________
> >>
>
> > R-help@
>
> > 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.
> >
> > ______________________________________________
>
> > R-help@
>
> > 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.
>
> Hi, I am sorry to reply so late. Actually, When I run these codes directly
> in R(not Rstudio), it also appears the problem but in a different type:
>
> > x<-read.csv("richness.csv")
> > x[1:5,]
> X..ÀíË.Æ. X.é.ð ÎïÖÖÊý
> 1 CK ×Ü 34
> 2 CK ×Ü 43
> 3 CK ×Ü 45
> 4 CK ×Ü 41
> 5 CK ×Ü 33
>
> So, what should I do solve this problem?
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Chinese-Garbled-
> tp4682184p4682302.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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