【发布时间】:2021-09-22 01:32:00
【问题描述】:
我输入了一些更可重现的代码,但错误仍然存在。
抱歉,没有更好的问题,示例代码在我进行更改之前就中断了。我以前也从未处理过“./{rest of url}”。是这个问题吗? 我正在处理这个 https://programminghistorian.org/en/lessons/geospatial-data-analysis
我收到此错误“错误:无法打开“./data/County1990ussm/”;该文件似乎不存在。”
我已经确认我在预期的工作目录中(数据文件夹的上一层)
“我们首先加载选定的数据。本教程的数据可以在这里下载 - https://programminghistorian.org/assets/geospatial-data-analysis/data.zip - 。下载后,将所有文件放在 R 中工作目录中标记为 data 的文件夹中。我们将创建一个变量并从变量目录中读取我们的数据。一旦运行,County_Aggregate_Data 变量将包含我们将分析的数据和地理信息:"
library(sf)
library(tmap)
library(plotly)
setwd("path")
aFile <- "https://programminghistorian.org/assets/geospatial-data-analysis/data.zip"
# check to see whether file exists before downloading and unzipping it
if(!file.exists("data.zip")) {
download.file(aFile,"data.zip",mode="wb")
unzip("data.zip")
}
print(list.files("./data"))
County_Aggregate_Data <- st_read("./data/County1990ussm/")
输出
"[1] "County1990_Data" "County1990ussm"
[3] "DP_TableDescriptions.xls" "ExtendedZIP5.csv"
[5] "GeocodedAddresses.csv" "Religion
"
"Error: Cannot open "./data/County1990ussm/" The file doesn't seem to exist."
【问题讨论】:
-
嗨,RuffGriffin,您能使用
list.files("data")和list.files("data/County1990ussm/")的输出吗? -
"data" _> [1] "County1990_Data" "County1990ussm" [3] "DP_TableDescriptions.xls" "ExtendedZIP5.csv" [5] "GeocodedAddresses.csv" "Religion" 1990ussm -> [ 1] "US_county_1990.dbf" "US_county_1990.prj" "US_county_1990.shp" [4] "US_county_1990.shx"