import-xls

R
data
Published

April 7, 2024

Question

Importieren Sie in R die Excel-Datei extra.xls.

Die Daten liegen online z.B. hier: https://github.com/sebastiansauer/statistik1/raw/main/daten/extra.xls

Es handelt sich um die Daten einer Umfrage zu den Korrelaten von Extraversion.

Ein Daten-Dictionary finden Sie hier.

Mehr Hinweise zu der zugrundeliegenden Studie finden Sie hier: https://osf.io/4kgzh.

Solution

Es gibt verschiedene Wege, Excel-Daten in R zu importieren. Hier ist ein Weg, mit Hilfe des Pakets {rio}:

library(rio)
extra_path <- "https://github.com/sebastiansauer/statistik1/raw/main/daten/extra.xls"
extra <- import(extra_path)

Test:

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.0     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
glimpse(extra)
Rows: 40
Columns: 25
$ X        <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
$ i1       <chr> "3/3/2016 15:33:23", "3/3/2016 15:33:28", "3/3/2016 15:34:43"…
$ i2       <chr> NA, "FBR", "CZP", NA, "ism", "Asm", "TPF", "Oam", "AEM", NA, …
$ i3       <dbl> 3, 3, 4, 4, 4, 4, 3, 2, 3, 4, 3, 4, 3, 4, 3, 3, 3, 4, 4, 4, 4…
$ i4       <dbl> 3, 3, 3, 3, 4, 3, 3, 2, 3, 3, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4…
$ i5       <dbl> 2, 3, 3, 3, 2, 3, 1, 3, 1, 2, 1, 1, 1, 3, 2, 4, 1, 2, 3, 3, 2…
$ i6       <dbl> 2, 4, 4, 3, 4, 4, 3, 3, 4, 3, 3, 3, 4, 3, 4, 4, 2, 3, 3, NA, …
$ i7       <dbl> 2, 3, 4, 3, 4, 3, 3, 3, 4, 3, 3, 2, 4, 4, 4, 3, 2, 3, 3, 4, 3…
$ i8       <dbl> 3, 3, 4, 4, 3, 3, 4, 2, 3, 3, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3…
$ i9       <dbl> 3, 2, 3, 3, 3, 4, 3, 1, 3, 3, 3, 2, 3, 3, 2, 4, 2, 4, 3, 3, 2…
$ i10      <dbl> 2, 2, 3, 4, 3, 3, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 3, 3, 2…
$ i11      <dbl> 3, 3, 3, 4, 3, 4, 4, 1, 3, 4, 3, 4, 3, 4, 3, 3, 2, 3, 4, 3, 3…
$ i12      <dbl> 1, 2, 2, 4, 2, 3, 2, 2, 2, 1, 3, 2, 3, 2, 2, 3, 2, 2, 2, 2, 1…
$ i13      <dbl> 250, 294, 600, 500, 300, 350, 608, NA, 500, 521, 280, 250, 12…
$ i14      <dbl> 1, 2, 0, 0, 0, 10, 2, 6, 10, 12, 12, 12, 20, 1, 3, 25, 0, 40,…
$ i15      <dbl> 24, 28, 24, 20, 20, 23, 24, 24, 21, 25, 23, 22, 23, 21, 22, 2…
$ i16      <chr> "Frau", "Frau", "Frau", "Frau", "Frau", "Frau", "Frau", "Mann…
$ i17      <dbl> 1, 3, 3, 3, 3, 3, 2, 3, 3, 2, 2, 2, 4, 3, 3, 4, 2, 3, 3, 3, 2…
$ i18      <dbl> NA, 27, NA, 7, 30, 15, 10, 15, 10, 10, 10, 10, 15, 1, 5, 1, 1…
$ i19      <chr> "nein", "ja", "nein", "nein", "nein", "nein", "nein", "nein",…
$ i20      <dbl> 6, 1, 30, 4, 5, 20, 30, 6, 5, 12, 30, 12, 22, 5, 15, 40, 48, …
$ i21      <chr> "im Schnitt 1 Mal pro Quartal (oder weniger)", "im Schnitt me…
$ i22      <chr> "keine Antwort", "passt insgesamt nicht", "passt insgesamt", …
$ i23      <dbl> 6, 4, 3, 3, 3, 3, 5, 4, 6, 5, 4, 6, 2, 3, 5, 2, 8, 6, 2, 4, 5…
$ extra_mw <dbl> 2.400000, 2.800000, 3.300000, 3.500000, 3.200000, 3.400000, 3…