Dear all,

I am trying to add and then display regional characteristics (e.g. population size) to an existing map. The map comes as a .shp file, including .sbn, .sbx, .shx and .dbf file and portrays municipality borders.  However, once I have added a new column to the .dbf file, I am unable to reread the .shp file and get the following error:
Error in `row.names<-.data.frame`(`*tmp*`, value = value) :   invalid 'row.names' length.

Here's what I do:

# To read the map:
munis <-readShapePoly("nl_1890.shp")

# To merge the new column with the original data:
munis2<-merge(munis,y, by.x="acode", by.y="hplts_adam_code", all.x)
# acode is key in the original file, to be merged with "hplts_adam_code" from the file containing regional information

head(munis2,3)
# acode GM_1890      GM_NAAM cbscode   famprop
# 1 10002    0136    Zuidlaren     136 1.0000000
# 2 10005    0086   Opsterland      86 1.0000000
# 3 10007    0981        Vaals     981 0.1250000

# Since I thought it was important, I changed the order of the variables back to the original order, with the added column "famprop" as last one:
munis2 <- munis2[c(2,3,4,1,5)]
# GM_1890    GM_NAAM cbscode acode famprop
# 1    0136  Zuidlaren     136 10002   1.000
# 2    0086 Opsterland      86 10005   1.000
# 3    0981      Vaals     981 10007   0.125

# next I write munis2 into the .dbf file (using the original name for the .dbf file)
write.dbf(munis2,"nl_1890")

# finally I try to read in the .shp file again
munis2shp <-readShapePoly("nl_1890.shp")

# but this result in the following error:
Error in `row.names<-.data.frame`(`*tmp*`, value = value) :
 invalid 'row.names' length

I am quite novice to R and mapping data, so any advice on either code or my approach is very much appreciated.

Best,

Richard






	[[alternative HTML version deleted]]

