Dear all

I've recently tried coloring different provinces in different colours for a
given country.  While I could do this on countries like US and UK, I came
across a problem when colouring China.  Would anybody know what's wrong
with the code/ any ways to get around the issue? Does this have anything to
do with Chinese language support in R? Many thanks.

Regards
Miriam

*Code:*

library(raster)
library(RColorBrewer)
library(ggplot2)

# Getting the data:

chn1<-getData('GADM', country="CHN", level=1)
class(chn1)

# Creating my (artificial) groupings of Chinese admin units:
nrofunits<-length(chn1$NAME_1)
print(chn1$NAME_1)
groups<-c(rep(1:3,(nrofunits %/%3)),rep(1,2))[order(c(rep(1:3,(nrofunits
%/% 3)),rep(1,2)))]

# adding values (grouping values) to "data" and calling this new variables
"groups"
chn1@data["groups"]<-groups
chn1@data$groups<-as.factor(chn1@data$groups)

mypalette<-brewer.pal(3,"Reds")
spplot(chn1,zcol="groups",col.regions=mypalette,colorkey
=FALSE,par.settings=list(axis.line=list(col='transparent')))


*Error:*

Error in sort.list(y) :
  invalid input 'æª¨á™žà¸¨à§‡ã¶˜ç¶¤ï¿¿Ã¿Ç«ÌŒæ¡¤æ±”' in 'utf8towcs'

	[[alternative HTML version deleted]]

