Note that there are some explanatory texts on larger screens.

plurals
  1. POError when loading a .shp file after joining attributes from a .csv to a .dbf file
    primarykey
    data
    text
    <p>I am having problems opening the .shp file in R after I have joined attributes from a csv file to the dbf file. I have a lot of experience coding in R, but limited experience with GIS in R. I have experience in ArcGIS, but do not have access to the program anymore. I know how to create bubbleplots and other maps in R using the csv file and plotting points, but I would like to be able to add the attributes to the .dbf, then use the shapefile to fill in the county areas with the brewer palette. I can open the shape file fine before joining the attributes to the .dbf file (the files were obtained from the us census bureau webpage).</p> <p>Here is my code below:</p> <pre><code>library(gpclib) library(maptools) library(RColorBrewer) library(classInt) library(TeachingDemos) gci&lt;-read.csv("C:/Users/Smackbug/marketingmapexample.csv", header=TRUE) #Has Geo_ID #read in dbf file to append data gci2&lt;-gci gci2&lt;-na.omit(gci2) #remove any empty data points #read in dbf file to add attributes akdbf&lt;-read.dbf(file.choose())#downloaded from the us census bureau #merge to join attributes joined&lt;-merge(akdbf,gci2, by=c("GEO_ID")) #Save original and new dbf write.dbf(akdbf, "C:/Users/Smackbug/Desktop/shapefiles/gz_2010_02_060_00_500koriginal.dbf") write.dbf(joined, "C:/Users/Smackbug/Desktop/shapefiles/gz_2010_02_060_00_500k.dbf") </code></pre> <p>and I get the error from this part of the code</p> <pre><code>**alaska&lt;-readShapePoly(file.choose(),proj4string=CRS("+proj=longlat") ) Error in `row.names&lt;-.data.frame`(`*tmp*`, value = value) : invalid 'row.names' length** </code></pre> <p>and the rest of the code</p> <pre><code>#the rest of the code should look something like this colors&lt;-brewer.pal(5,"Reds") brks&lt;-classIntervals(alaska$medianIncome, n=5, style="fixed", fixedBreaks=c(0,25,50,100,250)) plot(brks, pal=colors) brks&lt;-brks$brks plot(alaska, col=colors[findInterval(alaska$medianIncome, brks, all.inside=TRUE)], axes=F) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload