CommencerCommencer gratuitement

Reading a big.matrix object

In this exercise, you'll create your first file-backed big.matrix object using the read.big.matrix() function. The function is meant to look similar to read.table() but, in addition, it needs to know what type of numeric values you want to read ("char", "short", "integer", "double"), it needs the name of the file that will hold the matrix's data (the backing file), and it needs the name of the file to hold information about the matrix (a descriptor file). The result will be a file on the disk holding the value read in along with a descriptor file which holds extra information (like the number of columns and rows) about the resulting big.matrix object.

Cet exercice fait partie du cours

Scalable Data Processing in R

Afficher le cours

Instructions

  • Load the bigmemory package.
  • Use the read.big.matrix() function to read a file called "mortgage-sample.csv", which contains a header and is composed of integer values. In addition:
    • Create a backingfile called "mortgage-sample.bin", and
    • A descriptor file called "mortgage-sample.desc".
  • Find the dimensions of x using the dim() function.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Load the bigmemory package
___

# Create the big.matrix object: x
x <- ___(___, header = ___, 
                     type = ___, 
                     backingfile = ___, 
                     descriptorfile = ___)
    
# Find the dimensions of x
___
Modifier et exécuter le code