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.
This exercise is part of the course
Scalable Data Processing in R
Exercise 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"
.
- Create a backingfile called
- Find the dimensions of
x
using thedim()
function.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the bigmemory package
___
# Create the big.matrix object: x
x <- ___(___, header = ___,
type = ___,
backingfile = ___,
descriptorfile = ___)
# Find the dimensions of x
___