ID EN
System & OS

system2

R Base 3.6.2 🇮🇩 Bahasa Indonesia

system2 memanggil perintah OS yang ditentukan oleh perintah.

Syntax

R
system2(command, args = character(),
        stdout = "", stderr = "", stdin = "", input = NULL,
        env = character(), wait = TRUE,
        minimized = FALSE, invisible = TRUE, timeout = 0)

Arguments

Parameter Deskripsi
command the system command to be invoked, as a character string.
args a character vector of arguments to command.
stdout, stderr where output to stdout or stderr should be sent. Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file.
stdin should input be diverted? "" means the default, alternatively a character string naming a file. Ignored if input is supplied.
input if a character vector is supplied, this is copied one string per line to a temporary file, and the standard input of command is redirected to the file.
env character vector of name=value strings to set environment variables.
wait a logical (not NA) indicating whether the R interpreter should wait for the command to finish, or run it asynchronously. This will be ignored (and the interpreter will always wait) if stdout = TRUE or stderr = TRUE. When running the command asynchronously, no output will be displayed on the Rgui console in Windows (it will be dropped, instead).
timeout timeout in seconds, ignored if 0. This is a limit for the elapsed time running command in a separate process. Fractions of seconds are ignored.
minimized, invisible arguments that are accepted on Windows but ignored on this platform, with a warning.
minimized logical (not NA), indicates whether the command window should be displayed initially as a minimized window.
invisible logical (not NA), indicates whether the command window should be visible on the screen.

Return Value

Jika stdout = TRUE atau stderr = TRUE, vektor karakter memberikan output perintah, satu baris per string karakter. (Baris keluaran lebih dari 8095 byte akan dipecah.) Jika perintah tidak dapat dijalankan, kesalahan R akan dihasilkan. Jika perintah dijalankan tetapi memberikan status keluar bukan nol, hal ini akan dilaporkan dengan peringatan dan dalam atribut "status" hasilnya: atribut "errmsg" mungkin juga tersedia. Dalam kasus lain, nilai yang dikembalikan adalah kode kesalahan (0 untuk sukses), mengingat atribut yang tidak terlihat

Details

Berbeda dengan sistem, perintah selalu dikutip dengan shQuote, sehingga harus berupa perintah tunggal tanpa argumen. Untuk detail tentang bagaimana perintah ditemukan, lihat sistem. Di Windows, env hanya didukung untuk perintah seperti R dan make yang menerima variabel lingkungan pada baris perintahnya. Beberapa perintah Unix (seperti beberapa implementasi ls) mengubah keluarannya jika dianggap disalurkan atau dialihkan: stdout = TRUE menggunakan pipa sedangkan stdout = "some_file_name" menggunakan pengalihan. Karena cara penerapannya, pada stderr = TRUE yang mirip Unix menyiratkan stdout = TRUE: peringatan diberikan jika ini bukan yang ditentukan. Ketika batas waktu bukan nol, perintah dihentikan setelah jumlah detik yang ditentukan. Pengakhiran berfungsi untuk perintah umum, tetapi tidak dijamin: dimungkinkan untuk menulis a

See Also

system. shell and shell.exec.