平移阿拉斯加與夏威夷的幾何圖形
分析人員常會想依州或郡來繪製整個美國的資料;然而,因為阿拉斯加與夏威夷距離美國本土很遠,預設情況下會較不方便。常見的做法是為了地圖繪製而重新縮放並平移阿拉斯加與夏威夷,而 tidycensus 支援這項功能。你會在本練習中學到如何操作。
本練習屬於課程
在 R 中分析美國人口普查資料
練習說明
- 使用 tidycensus 的 geography 參數,按州索取家庭房價中位數資料。
- 使用
shift_geo參數,讓 tidycensus 傳回已平移且重新縮放的阿拉斯加與夏威夷幾何圖形。 - 繪製你建立的新資料集。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Get a dataset of median home values from the 1-year ACS
state_value <- ___(geography = ___,
___ = "B25077_001",
___ = "acs1",
geometry = ___,
___ = TRUE)
# Plot the dataset to view the shifted geometry
___(state_value["estimate"])