Get startedGet started for free

Copying matrices and big matrices

If you want to copy a big.matrix object, then you need to use the deepcopy() function. This can be useful, especially if you want to create smaller big.matrix objects. In this exercise, you'll copy a big.matrix object and show the reference behavior for these types of objects.

This exercise is part of the course

Scalable Data Processing in R

View Course

Exercise instructions

The big.matrix object mort is available in your workspace.

  • Create a new variable, first_three, which is an explicit copy of mort, but consists of only the first three columns.
  • Set another variable, first_three_2 to first_three.
  • Set the value in the first row and first column of first_three to NA.
  • Verify the change shows up in first_three_2 but not in mort.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Use deepcopy() to create first_three
first_three <- ___(___, cols = ___, 
                        backingfile = "first_three.bin", 
                        descriptorfile = "first_three.desc")

# Set first_three_2 equal to first_three
___ <- ___

# Set the value in the first row and first column of first_three to NA
first_three[___, ___] <- NA

# Verify the change shows up in first_three_2
first_three_2[1, 1]

# but not in mort
mort[1, 1]
Edit and Run Code