r - Importing CSV data from UN database -


i'm trying import refugee data unhcr http://popstats.unhcr.org/en/time_series

i export data , try import using read.csv function i've never had problems using before , receive following error code

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

for ref i've opened csv file in word , format in;

""extracted unhcr population statistics reference database","united nations high commissioner 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)"  

and appears in correct format i'm @ bit of loss what's going wrong.

thanks help

chris

your data have typos. should like:

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)) 

then import using read.table():

df=read.table("un.csv", header = t, sep=",") 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -