開始使用免費開始

設定快取目錄

來自美國 Census Bureau 的空間資料可能非常龐大,有時會有數百 MB。預設情況下,tigris 函式會從 Census Bureau 的網站下載資料;但如果你一再下載相同的大型資料集,就會變得很麻煩。為了解決這個問題,tigris 提供了在使用者電腦上快取下載資料的選項,讓檔案只需要從 Census 網站下載一次即可。在本練習中,你會熟悉 tigris 的快取功能。

本練習屬於課程

在 R 中分析美國人口普查資料

檢視課程

練習說明

  • 使用 tigris_cache_dir() 的模擬版本來設定一個假想的快取目錄。
  • tigris_use_cache 選項設為 TRUE,讓 tigris 會快取 shapefile。
  • 使用 getOption() 檢查你是否正確修改了快取選項。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Set the cache directory
___("Your preferred cache directory path would go here")

# Set the tigris_use_cache option
options(___ = ___)

# Check to see that you've modified the option correctly
___("tigris_use_cache")
編輯並執行程式碼