0

EDITED:

I have two sets of data and assigned them into two variables named Caifornia_shp and Houses. The information of these two variables are as follow:

head(California_shp)
       NAME
1   Alameda
2    Alpine
3    Amador
4     Butte
5 Calaveras
6    Colusa

head(Houses)
  houseValue income houseAge rooms bedrooms population households latitude longitude
1     452600 8.3252       41   880      129        322        126    37.88   -122.23
2     358500 8.3014       21  7099     1106       2401       1138    37.86   -122.22
3     352100 7.2574       52  1467      190        496        177    37.85   -122.24
4     341300 5.6431       52  1274      235        558        219    37.85   -122.25
5     342200 3.8462       52  1627      280        565        259    37.85   -122.25
6     269700 4.0368       52   919      213        413        193    37.85   -122.25 

I merged Houses and California_shp using the following codes:

pts.poly <- point.in.poly(Houses,California_shp)

head(pts.poly@data)

    houseValue income houseAge rooms bedrooms population households latitude longitude
    1     452600 8.3252       41   880      129        322        126    37.88   -122.23
    2     358500 8.3014       21  7099     1106       2401       1138    37.86   -122.22
    3     352100 7.2574       52  1467      190        496        177    37.85   -122.24
    4     341300 5.6431       52  1274      235        558        219    37.85   -122.25
    5     342200 3.8462       52  1627      280        565        259    37.85   -122.25
    6     269700 4.0368       52   919      213        413        193    37.85   -122.25
         NAME
    1 Alameda
    2 Alameda
    3 Alameda
    4 Alameda
    5 Alameda
    6 Alameda

head(tapply(pts.poly@data$houseValue,list(pts.poly@data$NAME),mean))
  Alameda    Alpine    Amador     Butte Calaveras    Colusa 
208747.39 118700.00 117146.43  89611.54 107893.75  77731.25

I want to plot the following thematic map of houseValue variable, but I do not know how I can plot it.

enter image description here

Rojer
  • 315
  • 2
  • 8
  • I'd like to try to help you solve this; are you able to share an MRE? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Skaqqs Jul 06 '21 at 18:58

0 Answers0