【发布时间】:2017-04-13 06:24:07
【问题描述】:
我正在尝试复制以下代码来模拟一些图表,但在下载时出现错误(我猜)并读取 .csv 文件。问题是我不知道如何或在哪里创建“输入”目录,如何将路径放在命令行中以及是否会下载数据。有人可以帮忙吗?感谢您的宝贵时间!
library(idbr)
library(countrycode)
library(ggplot2)
library(animation)
library(dplyr)
countries <- c("France", "Switzerland", "Japan", "China", "United States", "Brazil", "Russia", "Morocco")
country.iso2 <- countrycode(countries, "country.name", "fips104")
translation.file <- "input/Population structures past and forecast - Sheet1.csv"
downloadData <- F
years <- 1990:2050
apikey <- "901083ee90dbd111d13f5e270ca00b4abf654be6"
data.file <- paste0("input/", paste(range(years), collapse = "_"), "_",
paste(country.iso2, collapse = "_"), ".csv")
### load translations
txt <- read.csv(translation.file, row.names = 1, stringsAsFactors = F)
Error in file(file, "rt") : no se puede abrir la conexión
Además: Warning message:
In file(file, "rt") :
no fue posible abrir el archivo 'input/Population structures past and forecast - Sheet1.csv': No such file or directory
【问题讨论】:
-
请适当标记您的问题。看来您使用的是
R,所以添加它。 -
@Ansjovis86 我的印象是OP没有在当前工作目录中创建
input目录,这会阻止R创建csv文件。