ID EN
I/O & Files

save

R Base 3.6.2 🇮🇩 Bahasa Indonesia

save menulis representasi eksternal objek R ke file yang ditentukan. Objek dapat dibaca kembali dari file di kemudian hari dengan menggunakan fungsi memuat atau melampirkan (atau data dalam beberapa kasus). save.image() hanyalah jalan pintas untuk 'simpan ruang kerja saya saat ini', yaitu save(list = ls(all.names = TRUE), file = ".RData", envir = .GlobalEnv). Hal ini juga terjadi dengan q("yes").

Syntax

R
save(…, list = character(),
     file = stop("'file' must be specified"),
     ascii = FALSE, version = NULL, envir = parent.frame(),
     compress = isTRUE(!ascii), compression_level,
     eval.promises = TRUE, precheck = TRUE)<p></p><p>save.image(file = ".RData", version = NULL, ascii = FALSE,
           compress = !ascii, safe = TRUE)</p>

Arguments

Parameter Deskripsi
&#8230; the names of the objects to be saved (as symbols or character strings).
list A character vector containing the names of objects to be saved.
file a (writable binary-mode) connection or the name of the file where the data will be saved (when tilde expansion is done). Must be a file name for save.image or version = 1.
ascii if TRUE, an ASCII representation of the data is written. The default value of ascii is FALSE which leads to a binary file being written. If NA and version >= 2, a different ASCII representation is used which writes double/complex numbers as binary fractions.
version the workspace format version to use. NULL specifies the current default format (3). Version 1 was the default from R 0.99.0 to R 1.3.1 and version 2 from R 1.4.0 to 3.5.0. Version 3 is supported from R 3.5.0.
envir environment to search for objects to be saved.
compress logical or character string specifying whether saving to a named file is to use compression. TRUE corresponds to gzip compression, and character strings "gzip", "bzip2" or "xz" specify the type of compression. Ignored when file is a connection and for workspace format version 1.
compression_level integer: the level of compression to be used. Defaults to 6 for gzip compression and to 9 for bzip2 or xz compression.
eval.promises logical: should objects which are promises be forced before saving?
precheck logical: should the existence of the objects be checked before starting to save (and in particular before opening the file/connection)? Does not apply to version 1 saves.
safe logical. If TRUE, a temporary file is used for creating the saved workspace. The temporary file is renamed to file if the save succeeds. This preserves an existing workspace file if the save fails, but at the cost of using extra disk space during the save.

Details

Nama objek yang ditentukan baik sebagai simbol (atau string karakter) di… atau sebagai vektor karakter dalam daftar digunakan untuk mencari objek dari lingkungan sekitar. Secara default janji dievaluasi, tetapi jika eval.promises = FALSE janji disimpan (bersama dengan lingkungan evaluasinya). (Janji yang tertanam dalam objek selalu disimpan tanpa dievaluasi.) Semua platform R menggunakan representasi XDR (bigendian) dari C int dan doubles dalam file biner save-d, dan ini portabel di semua platform R. Penyimpanan ASCII dulunya berguna untuk memindahkan data antar platform, namun kini lebih banyak digunakan untuk kepentingan historis. Mereka bisa lebih kompak daripada penyimpanan biner di mana kompresi tidak digunakan, tetapi hampir selalu lebih lambat untuk membaca dan menulis: kompresi penyimpanan biner jauh lebih baik daripada yang ASCII. Selanjutnya

Contoh

Example
R
# NOT RUN {
x <- stats::runif(20)
y <- list(a = 1, b = TRUE, c = "oops")
save(x, y, file = "xy.RData")
save.image() # creating ".RData" in current working directory
unlink("xy.RData")

# set save defaults using option:
options(save.defaults = list(ascii = TRUE, safe = FALSE))
save.image() # creating ".RData"
if(interactive()) withAutoprint({
   file.info(".RData")
   readLines(".RData", n = 7) # first 7 lines; first starts w/ "RDA"..
})
unlink(".RData")
# }

See Also

dput dump load data. For other interfaces to the underlying serialization format see serialize and saveRDS.