ID EN
Math Functions

difftime

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Pembuatan interval waktu, pencetakan, dan beberapa aritmatika. Metode print() menyebut “perbedaan waktu” ini.

Syntax

R
<code>time1 - time2</code><p></p><p>difftime(time1, time2, tz,
         units = c("auto", "secs", "mins", "hours",
                   "days", "weeks"))</p><p>as.difftime(tim, format = "%X", units = "auto")</p><p># S3 method for difftime
format(x, ...)
# S3 method for difftime
units(x)
# S3 method for difftime
units(x) &lt;- value
# S3 method for difftime
as.double(x, units = "auto", ...)</p><p>## Group methods, notably for round(), signif(), floor(),
## ceiling(), trunc(), abs(); called directly, *not* as Math():
# S3 method for difftime
Math(x, &#8230;)</p>

Arguments

Parameter Deskripsi
time1, time2 date-time or date objects.
tz an optional time zone specification to be used for the conversion, mainly for "POSIXlt" objects.
units character string. Units in which the results are desired. Can be abbreviated.
value character string. Like units, except that abbreviations are not allowed.
tim character string or numeric value specifying a time interval.
format character specifying the format of tim: see strptime. The default is a locale-specific time format.
x an object inheriting from class "difftime".
&#8230; arguments to be passed to or from other methods.

Details

Fungsi difftime menghitung perbedaan dua objek tanggal/waktu dan mengembalikan objek kelas "difftime" dengan atribut yang menunjukkan satuannya. Metode grup Matematika menyediakan metode bulat, signifikan, lantai, langit-langit, trunc, abs, dan tanda untuk objek kelas ini, dan terdapat metode untuk operasi logika dan aritmatika grup-generik (lihat Ops). Jika unit = "otomatis", sekumpulan unit yang sesuai dipilih, kemungkinan terbesar (tidak termasuk "minggu") yang semua perbedaan absolutnya lebih besar dari satu. Pengurangan objek tanggal-waktu menghasilkan objek kelas ini, dengan memanggil difftime dengan unit = "auto". Alternatifnya, as.difftime() bekerja pada interval waktu berkode karakter atau numerik; dalam kasus terakhir, unit harus ditentukan, dan format tidak berpengaruh. Aritmatika terbatas tersedia

Contoh

Example
R
# NOT RUN {
(z <- Sys.time() - 3600)
Sys.time() - z                # just over 3600 seconds.

## time interval between release days of R 1.2.2 and 1.2.3.
ISOdate(2001, 4, 26) - ISOdate(2001, 2, 26)

as.difftime(c("0:3:20", "11:23:15"))
as.difftime(c("3:20", "23:15", "2:"), format = "%H:%M") # 3rd gives NA
(z <- as.difftime(c(0,30,60), units = "mins"))
as.numeric(z, units = "secs")
as.numeric(z, units = "hours")
format(z)
# }

See Also

DateTimeClasses.