我正在尝试通过压裂使用的水量来填充流域。我有数据集(well_watershed_ok)和变量(H2O_BBL_T)。每个分水岭都有一个值。这是我使用的代码。
ggplot() +
geom_polygon(data = well_watershed_ok, aes(x = long, y = lat),
fill = well_watershed_ok$H2O_BBL_T) +
labs(x = "", y = "", title = "Number of Barrells of Water used per Day") +
scale_color_gradientn("Water BBL/Day", colors = c( "#660000", "#f9f3c2")) +
theme(legend.position = "bottom", axis.ticks.y = element_blank(),
axis.text.y = element_blank(), axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
plot.title = element_text(lineheight = .8, face="bold", vjust = 1, size = 12)) +
coord_equal(ratio=1)
Regions defined for each Polygons
Error: Aesthetics must be either length 1 or the same as the data (222074): fill
因为我收到了这个错误,所以我检查了我的长度并且它们是相等的,但是我检查了计算机是否识别出它们是相等的并且它是错误的。我该怎么办?
identical(well_watershed_ok,well_watershed_ok$H2O_BBL_T)
[1] FALSE
length(well_watershed_ok)
[1] 79
length(well_watershed_ok$H2O_BBL_T)
[1] 79
这是我的数据的样子
data.frame': 79 obs. of 37 variables:
$ FID_1 : Factor w/ 79 levels "0","1","10","11",..: 1 2 13 24 35 46 57 68
78 79 ...
$ HUC_8 : Factor w/ 68 levels "11040001","11040002",..: 1 2 3 3 3 3 4 5 6
7 ...
$ ACRES : num 26176 420687 188128 1281 657 ...
$ HU_8_NAME : Factor w/ 68 levels "11040001 - CIMARRON HEADWATERS",..: 1 2 3 3
3 3 4 5 6 7 ...
$ STATES : Factor w/ 8 levels "AR,OK","AR,OK,TX",..: 5 7 3 3 3 3 3 7 7 7 ...
$ SQ_MILES : num 40.9 657.32 293.95 2 1.03 ...
$ Count_ : Factor w/ 40 levels "0","1","10","12",..: 1 14 17 2 1 34 1 20 26
16 ...
$ Sum_Lat_Y : num 0 73.8 775.6 37 0 ...
$ Sum_Long_X: num 0 -204 -2111 -101 0 ...
$ Sum_DF_Ele: num 0 0 0 0 0 ...
$ Sum_GF_Ele: num 0 7691 54745 3223 0 ...
$ Sum_Total_: num 0 9389 144678 6720 0 ...
$ Sum_OilBBL: num 0 0 0 0 0 0 0 181 166 698 ...
$ Sum_Oil_Gr: num 0 0 0 0 0 ...
$ Sum_GasMCF: num 0 0 0 0 0 ...
$ Sum_GasOil: num 0 0 0 0 0 ...
$ Sum_WaterB: num 0 0 0 0 0 ...
$ H2O_BBL_T : num 0 642 0 0 0 ...
$ FID_12 : Factor w/ 79 levels "0","1","10","11",..: 1 2 13 24 35 46 57 68
78 79 ...
$ FID_12_13 : Factor w/ 79 levels "0","1","10","11",..: 1 2 13 24 35 46 57 68
78 79 ...
$ HUC_89 : Factor w/ 68 levels "11040001","11040002",..: 1 2 3 3 3 3 4 5 6
7 ...
$ ACRES_1 : num 26176 420687 188128 1281 657 ...
$ HU_8_NAM_1: Factor w/ 68 levels "11040001 - CIMARRON HEADWATERS",..: 1 2 3 3
3 3 4 5 6 7 ...
$ STATES_1 : Factor w/ 8 levels "AR,OK","AR,OK,TX",..: 5 7 3 3 3 3 3 7 7 7
...
$ SQ_MILES_1: num 40.9 657.32 293.95 2 1.03 ...
$ Count1 : Factor w/ 39 levels "0","1","107",..: 1 24 2 1 1 14 1 31 5 22
...
$ Sum_DF_E_1: num 0 0 0 0 0 ...
$ Sum_GF_E_1: num 0 12299 2499 0 0 ...
$ Sum_Total1: num 0 20844 6950 0 0 ...
$ Sum_OilB_1: num 0 20 0 0 0 ...
$ Sum_Oil__1: num 0 0 0 0 0 ...
$ Sum_GasM_1: num 0 20 0 0 0 ...
$ Sum_GasO_1: num 0 1000 0 0 0 ...
$ Sum_Wate_1: num 0 642 0 0 0 ...