2016-11-29 1 views
0

일부 차트를 시뮬레이트하기 위해 다음 코드를 복제하려고하는데 다운로드 할 때 오류가 발생하여 .csv 파일을 읽었습니다. 문제는 "input"디렉토리를 어떻게, 어디서 만들지, 명령 행에 경로를 넣는 방법, 그리고 데이터가 다운로드 될지 모르기 때문입니다. 아무도 도울 수 없나요? 시간 내 줘서 고마워! r create dir에 대한 인터넷 검색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 
+0

질문에 적절하게 태그를 답니다. 당신이'R'을 사용하고있는 것처럼 보입니다. 그래서 그것을 추가하십시오. –

+0

@ Ansjovis86 내 인상은 OP가 현재 작업 디렉토리에'input' 디렉토리를 만들지 않아서 R이 csv 파일을 만들지 못하게한다는 것입니다. –

답변

0

는 디렉토리를 만들 dir.create를 사용할 수 있음을 보여줍니다 this SO question를 알려준. 디렉토리를 작성한 위치 (예 : 홈 드라이브)에 쓰기 권한이 있어야합니다. tempdir()을 사용하면 물건을 저장할 수있는 임시 디렉토리를 얻을 수 있습니다. 이는 Linux, Windows 및 Mac에서 이식 가능합니다.