Ist das Problem, dass Sie die 2013 Daten fehlen?
heruntergeladen ich die Datei zu diesem Link, entpackt es ein Kommandozeilen-Tool verwenden, und dann kann es ganz gut importiert werden, um die readr Bibliothek:
library(readr)
immigration <- read_tsv("~/Downloads/migr_imm10ctb.tsv", na = ":")
#> Parsed with column specification:
#> cols(
#> `age,agedef,c_birth,unit,sex,geo\time` = col_character(),
#> `2015` = col_character(),
#> `2014` = col_character(),
#> `2013` = col_character()
#>)
immigration
#> # A tibble: 45,558 x 4
#> `age,agedef,c_birth,unit,sex,geo\\time` `2015` `2014` `2013`
#> <chr> <chr> <chr> <chr>
#> 1 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,AT 4723 4093 4085
#> 2 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,BE 1017 953 1035
#> 3 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,BG 559 577 743 p
#> 4 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CH 2876 2766 2758
#> 5 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CY <NA> <NA> 54
#> 6 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CZ 120 106 155
#> 7 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,DE <NA> <NA> 14984
#> 8 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,DK 372 365 405
#> 9 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,EE 23 7 16
#> 10 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,EL <NA> <NA> 234
#> # ... with 45,548 more rows
Sieht aus wie es einige Ersatz Zeichen herumschweben (743 p
), wo es nur Zahlen geben sollte, so müssen Sie mehr Reinigung und dann in numerische konvertieren.
library(dplyr)
library(stringr)
immigration %>%
mutate_at(vars(`2015`:`2013`), str_extract, pattern = "[0-9]+") %>%
mutate_at(vars(`2015`:`2013`), as.numeric)
#> # A tibble: 45,558 x 4
#> `age,agedef,c_birth,unit,sex,geo\\time` `2015` `2014` `2013`
#> <chr> <dbl> <dbl> <dbl>
#> 1 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,AT 4723 4093 4085
#> 2 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,BE 1017 953 1035
#> 3 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,BG 559 577 743
#> 4 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CH 2876 2766 2758
#> 5 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CY NA NA 54
#> 6 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,CZ 120 106 155
#> 7 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,DE NA NA 14984
#> 8 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,DK 372 365 405
#> 9 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,EE 23 7 16
#> 10 TOTAL,COMPLET,CC5_13_FOR_X_IS,NR,F,EL NA NA 234
#> # ... with 45,548 more rows
Es ist eine tabstoppgetrennte Datei, aber das erste Spalte alle mit Komma zusammen, also, wenn, was Sie wollen, dass die Informationen herausgetrennt ist, können Sie mit tidyr::separate()
tun könnte.
library(tidyr)
immigration %>%
separate(`age,agedef,c_birth,unit,sex,geo\\time`,
c("age", "agedef", "c_birth", "unit", "sex", "geo"),
sep = ",")
#> # A tibble: 45,558 x 9
#> age agedef c_birth unit sex geo `2015` `2014` `2013`
#> * <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 TOTAL COMPLET CC5_13_FOR_X_IS NR F AT 4723 4093 4085
#> 2 TOTAL COMPLET CC5_13_FOR_X_IS NR F BE 1017 953 1035
#> 3 TOTAL COMPLET CC5_13_FOR_X_IS NR F BG 559 577 743 p
#> 4 TOTAL COMPLET CC5_13_FOR_X_IS NR F CH 2876 2766 2758
#> 5 TOTAL COMPLET CC5_13_FOR_X_IS NR F CY <NA> <NA> 54
#> 6 TOTAL COMPLET CC5_13_FOR_X_IS NR F CZ 120 106 155
#> 7 TOTAL COMPLET CC5_13_FOR_X_IS NR F DE <NA> <NA> 14984
#> 8 TOTAL COMPLET CC5_13_FOR_X_IS NR F DK 372 365 405
#> 9 TOTAL COMPLET CC5_13_FOR_X_IS NR F EE 23 7 16
#> 10 TOTAL COMPLET CC5_13_FOR_X_IS NR F EL <NA> <NA> 234
#> # ... with 45,548 more rows
Die Tabelle, die Sie sich beziehen, ist nicht eine Textdatei mit Tabulatoren getrennte Werte ... – ssp3nc3r
die Datei in ein nutzbares Format hier herunterladen: http://appsso.eurostat.ec.europa.eu /nui/setupDownloads.do – ssp3nc3r
Die Seite sagt "Session ungültig!" – neutral