I have data in shapefile format :: UK_boundaries I am new to R and Spatial data as well, I am trying to join some areas to be as one area no line(s) between them. Based on my search I understand that unionSpatialPolygons function dissolves polygons but when I tried to use it I got error: Error: TopologyException: Input geom 0 is invalid: Self-intersection at or near point 162544.73551388 516922.55880385998 at 162544.73551388 516922.55880385998
libs <- c("rgdal", "maptools", "gridExtra", "rgeos", "raster")
lapply(libs, require, character.only = TRUE)
LA <- readOGR(dsn = ".", layer = "infuse_dist_lyr_2011_clipped")
IDs <- LA$geo_code
IDs[IDs %in% c("95DD","95II","95QQ","95EE","95RR","95UU","95TT","95CC","95BB")] <- c("95AA","95GG","95HH","95JJ","95JJ","95JJ","95KK","95OO","95XX")
LA_new <- unionSpatialPolygons(LA, IDs)
In summary I want areas of the same colour shown here to be joined.

Any help please?
gpclibPermit()returns a warning message saying "support for gpclib will be withdrawn from maptools at the next major release" - seems like it won't be much longer before this very nice workaround is doomed to fail... – fdetsch Feb 13 '15 at 09:57package ‘gpclib’ is available as a source package but not as a binary
Warning in install.packages : package ‘gpclib’ is not available (for R version 3.0.2)
although according to its description it should be installed for R( > 2.14.0)gpclib
– Iman Feb 13 '15 at 10:32