Matrizen und Big-Matrizen kopieren
Wenn du ein big.matrix-Objekt kopieren willst, musst du die Funktion deepcopy() verwenden. Das ist besonders nützlich, wenn du kleinere big.matrix-Objekte erstellen möchtest. In dieser Übung kopierst du ein big.matrix-Objekt und zeigst das Referenzverhalten für diese Objekttypen.
Diese Übung ist Teil des Kurses
Skalierbare Datenverarbeitung in R
Anleitung zur Übung
Das big.matrix-Objekt mort ist in deinem Workspace verfügbar.
- Erstelle eine neue Variable
first_three, die eine explizite Kopie vonmortist, aber nur aus den ersten drei Spalten besteht. - Setze eine weitere Variable
first_three_2auffirst_three. - Setze den Wert in der ersten Zeile und ersten Spalte von
first_threeaufNA. - Überprüfe, dass die Änderung in
first_three_2sichtbar ist, aber nicht inmort.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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]