BaşlayınÜcretsiz başlayın

Reading raw data and turning it into a data structure

As mentioned before, part of what makes iotools fast is that it separates reading data from the hard drive from converting the binary data it into a data.frame or matrix. Data in their binary format are copied from the hard drive into memory as raw objects. These raw objects are then passed to optimized functions that turn them into data.frame or matrix objects.

In this exercise, you'll learn how to separate reading data from the disk (using the readAsRaw() function), and then convert the raw binary data into a matrix or data.frame (using the mstrsplit() and dstrsplit() functions).

Bu egzersiz, kursun bir parçasıdır

Scalable Data Processing in R

Kursa Göz Atın

Egzersiz talimatları

  • Read "mortgage-sample.csv" as a raw vector.
  • Convert the raw vector contents to a matrix of integers.
  • Convert the raw vector contents to a data.frame with 16 integer columns.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Read mortgage-sample.csv as a raw vector
raw_file_content <- ___("mortgage-sample.csv")

# Convert the raw vector contents to a matrix
mort_mat <- ___(___, sep = ",", type = ___, skip = 1)

# Look at the first 6 rows
head(mort_mat)

# Convert the raw file contents to a data.frame
mort_df <- ___(___, sep = ",", col_types = rep("integer", 16), skip = 1)

# Look at the first 6 rows
head(mort_df)
Kodu Düzenle ve Çalıştır