Abschluss

Einführung in das Importieren von Daten in R

Filip Schouwenaars

Instructor, DataCamp

Wrapper

  • read.table() ist die Hauptfunktion

  • read.csv() = Wrapper für CSV

  • read.delim() = Wrapper für Tab-getrennte Dateien

Einführung in das Importieren von Daten in R

read.csv

states.csv

state,capital,pop_mill,area_sqm
South Dakota,Pierre,0.853,77116
New York,Albany,19.746,54555
Oregon,Salem,3.970,98381
Vermont,Montpelier,0.627,9616
Hawaii,Honolulu,1.420,10931
  • Standardwerte
    • header = TRUE
    • sep = ","
read.table("states.csv", header = TRUE, sep = ",")
read.csv("states.csv")
Einführung in das Importieren von Daten in R

read.delim

states.txt

state   capital pop_mill    area_sqm
South Dakota    Pierre  0.853   77116
New York    Albany  19.746  54555
Oregon  Salem  3.970   98381
Vermont Montpelier  0.627   9616
Hawaii  Honolulu    1.420   10931
  • Standardwerte
    • header = TRUE
    • sep = "\t"
read.table("states.txt", header = TRUE, sep = "\t")
read.delim("states.txt")
Einführung in das Importieren von Daten in R

Dokumentation

?read.table

Screenshot 16.07.2019 um 11:28:18.png

Einführung in das Importieren von Daten in R

Locale-Unterschiede

states_aye.csv

state,capital,pop_mill,area_sqm
South Dakota,Pierre,0.853,77116
New York,Albany,19.746,54555
Oregon,Salem,3.970,98381
Vermont,Montpelier,0.627,9616
Hawaii,Honolulu,1.420,10931
states_nay.csv

state;capital;pop_mill;area_sqm
South Dakota;Pierre;0,853;77116
New York;Albany;19,746;54555
Oregon;Salem;3,97;98381
Vermont;Montpelier;0,627;9616
Hawaii;Honolulu;1,42;10931
Einführung in das Importieren von Daten in R

Locale-Unterschiede

read.csv(file, header = TRUE, sep = ",", quote = "\"",
         dec = ".", fill = TRUE, comment.char = "", ...)

read.csv2(file, header = TRUE, sep = ";", quote = "\"",
          dec = ",", fill = TRUE, comment.char = "", ...)
read.delim(file, header = TRUE, sep = "\t", quote = "\"",
           dec = ".", fill = TRUE, comment.char = "", ...)

read.delim2(file, header = TRUE, sep = "\t", quote = "\"",
            dec = ",", fill = TRUE, comment.char = "", ...)
Einführung in das Importieren von Daten in R

states_nay.csv

read.csv("states_nay.csv")

                      state.capital.pop_mill.area_sqm
South Dakota;Pierre;0                       853;77116
New York;Albany;19                          746;54555
Oregon;Salem;3                               97;98381
Vermont;Montpelier;0                         627;9616
Hawaii;Honolulu;1                            42;10931
read.csv2("states_nay.csv")
         state    capital pop_mill area_sqm
1 South Dakota     Pierre    0.853    77116
2     New York     Albany   19.746    54555
3       Oregon      Salem    3.970    98381
4      Vermont Montpelier    0.627     9616
5       Hawaii   Honolulu    1.420    10931
Einführung in das Importieren von Daten in R

Lass uns üben!

Einführung in das Importieren von Daten in R

Preparing Video For Download...