[R-sig-Geo] How can I add attribute data to map?

Carson Farmer carson.farmer at gmail.com
Sat Nov 27 20:04:54 CET 2010

Assuming the attribute table you want to join to your county layer is
called new.data, the following might be what you're looking for:

temp.data <- county at data
         # get the data.frame of your county Spatial*DataFrame
temp.data <- merge(temp.data, new.data, by='code', all.x=TRUE) # join
your new.data to your temp.data data.frame

                        # in this case, a left outer join, which is
probably what you want...
county at data <- temp.data
         # now add the data back (along with the new fields)

Hope that helps,


On 27 November 2010 03:33, lu <lufile at 126.com> wrote:
> Hello,
>  I have import map data (county) into R and the fields of  its data are code, name. Now I want to add attribute data to the map. The fields of the attribute data are code,var1,var2,var3,var4,var5,var6,var7 . How can I add the attribute data to the map according to the code fields ?Thanks!
>        [[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation
National University of Ireland, Maynooth,

More information about the R-sig-Geo mailing list