開始使用免費開始

複製矩陣與大型矩陣

若你想要複製 big.matrix 物件,必須使用 deepcopy() 函式。這在你想建立較小的 big.matrix 物件時特別實用。在本練習中,你會複製一個 big.matrix 物件,並示範這類物件的參照行為。

本練習屬於課程

R 的可擴展資料處理

檢視課程

練習說明

工作區中已提供 big.matrix 物件 mort

  • 建立新變數 first_three,它是 mort 的顯式複本,但只包含前 3 欄。
  • 將另一個變數 first_three_2 指向 first_three
  • first_three 的第 1 列第 1 欄設為 NA
  • 驗證變更會出現在 first_three_2,但不會出現在 mort

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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]
編輯並執行程式碼