يمكن حفظ مصفوفه (matrix) كملف نصي (txt) او قراءتها في آر R، كما يلي:
> library(MASS) > x=matrix(1:6, nrow = 2, ncol = 3) > x [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > #Write: > write.matrix(x, file = "matrix.txt", sep = " ") > #Read: > new_x = matrix(scan('matrix.txt'), ncol = 3, byrow = TRUE) Read 6 items > new_x [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6