2017-03-28 1 views
0

다음 오류 코드가져 오기 CSV 데이터 내가 데이터를 내보내 UNHCR <a href="http://popstats.unhcr.org/en/time_series" rel="nofollow noreferrer">http://popstats.unhcr.org/en/time_series</a></p> <p>에서 난민 데이터를 가져 와서 내가 문제가 전에 사용하고받을 수 없었 한 <code>read.csv</code> 기능을 사용하여 가져 오려고 노력하고있어

un <- read.csv("un.csv", na.strings = "..") 
Error in read.table(file = file, header = header, sep = sep, quote = quote, : 
    more columns than column names 

(ref 용) csv 파일을 단어로 열었습니다.이 형식은 그대로입니다.

""Extracted from the UNHCR Population Statistics Reference Database","United Nations High Commissioner for Refugees" 
"Date extracted: 2015-09-18 04:37:24 +02:00" 

Year,"Country/territory of asylum/residence",Origin,"Population type",Value 
1951,Australia,Various/Unknown,"Refugees (incl. refugee-like situations)",180000 
1951,Austria,Various/Unknown,"Refugees (incl. refugee-like situations)",282000 
1951,Belgium,Various/Unknown,"Refugees (incl. refugee-like situations)",55000 
1951,Canada,Various/Unknown,"Refugees (incl. refugee-like situations)",168511 
1951,Switzerland,Various/Unknown,"Refugees (incl. refugee-like situations)" 

그래서 올바른 형식으로 표시되므로 잘못 될 수 있습니다. 당신의 도움에 대한

덕분에

크리스

+1

열. 방법은'? read.csv'를보십시오. – dash2

+0

괜찮아요. 저에게 도움이되었습니다. 고맙습니다. 시간 내 주셔서 감사합니다. –

답변

0

귀하의 데이터는 오타가 있습니다.

un = structure(list(Year = c(1951L, 1951L, 1951L, 1951L, 1951L), Country...territory.of.asylum.residence = structure(1:5, .Label = c("Australia", 
"Austria", "Belgium", "Canada", "Switzerland"), class = "factor"), 
    Origin = structure(c(1L, 1L, 1L, 1L, 1L), .Label = "Various/Unknown", class = "factor"), 
    Population.type = structure(c(1L, 1L, 1L, 1L, 1L), .Label = "Refugees (incl. refugee-like situations)", class = "factor"), 
    Value = c(180000, 282000, 55000, 168511, NA)), .Names = c("Year", 
"Country...territory.of.asylum.residence", "Origin", "Population.type", 
"Value"), class = "data.frame", row.names = c(NA, -5L)) 

그런 다음 당신은 쉽게 read.table ()를 사용하여 가져올 수 :처럼 그것은해야

당신은 당신의 데이터가 다섯을 가지고있는 동안 참으로 네 개의 열이 첫 번째 줄을 건너 뛸 필요가
df=read.table("un.csv", header = T, sep=",") 
관련 문제