找回密码
 注册
查看: 5173|回复: 0

R语言:difftime()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:35:20 | 显示全部楼层 |阅读模式
difftime(base)
difftime()所属R语言包:base

                                        Time Intervals
                                         时间间隔

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Time intervals creation, printing, and some arithmetic.
时间间隔创建,打印,和一些算术。


用法----------Usage----------


time1 - time2

difftime(time1, time2, tz,
         units = c("auto", "secs", "mins", "hours",
                   "days", "weeks"))

as.difftime(tim, format = "%X", units = "auto")

## S3 method for class 'difftime'
format(x, ...)
## S3 method for class 'difftime'
units(x)
## S3 replacement method for class 'difftime'
units(x) <- value
## S3 method for class 'difftime'
as.double(x, units = "auto", ...)

## Group methods, notably for round(), signif(), floor(),
## ceiling(), trunc(), abs(); called directly, *not* as Math():
## S3 method for class 'difftime'
Math(x, ...)



参数----------Arguments----------

参数:time1, time2
date-time or date objects.
日期,时间或日期对象。


参数:tz
an optional timezone specification to be used for the conversion, mainly for "POSIXlt" objects.
一个可选的时区规范转换,主要用于"POSIXlt"对象。


参数:units
character string.  Units in which the results are desired.  Can be abbreviated.
字符串。结果所需的单位。可以缩写。


参数:value
character string.  Like units, except that abbreviations are not allowed.
字符串。像units,除了缩略语不允许。


参数: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.
指定字符格式:见timstrptime。默认的是一个特定于语言环境的时间格式。


参数:x
an object inheriting from class "difftime".
继承类"difftime"对象。


参数:...
arguments to be passed to or from other methods.
参数被传递到或从其他方法。


Details

详情----------Details----------

Function difftime calculates a difference of two date/time objects and returns an object of class "difftime" with an attribute indicating the units.  The Math group method provides round, signif, floor, ceiling, trunc, abs, and sign methods for objects of this class, and there are methods for the group-generic (see Ops) logical and arithmetic operations.
difftime计算两个日期/时间对象的差异,并返回一个类对象的功能"difftime"属性表示单位。 Math组方法提供round,signif,floor,ceiling,trunc,abs,sign 这个类的对象,方法和有组通用(见Ops)逻辑和算术运算的方法。

If units = "auto", a suitable set of units is chosen, the largest possible (excluding "weeks") in which all the absolute differences are greater than one.
如果units = "auto",选择一套合适的单位,最大的可能(不包括"weeks"),其中所有的绝对差异大于一。

Subtraction of date-time objects gives an object of this class, by calling difftime with units = "auto".  Alternatively, as.difftime() works on character-coded or numeric time intervals; in the latter case, units must be specified, and format has no effect.
减法的日期时间对象给出了这个类的对象,通过调用difftimeunits = "auto"。另外,as.difftime()工程编码字符或数字的时间间隔,在后一种情况下,必须指定单位,format有没有效果。

Limited arithmetic is available on "difftime" objects: they can be added or subtracted, and multiplied or divided by a numeric vector. In addition, adding or subtracting a numeric vector by a "difftime" object implicitly converts the numeric vector to a "difftime" object with the same units as the "difftime" object.  There are methods for mean and sum (via the Summary group generic).
"difftime"对象提供有限的算术是:他们可以添加或减去,乘以或除以一个数值向量。此外,加上或减去一个数值向量"difftime"对象隐式转换成数字矢量"difftime""difftime"对象相同的单位的对象。有mean和sum通过Summary组通用的方法。

The units of a "difftime" object can be extracted by the units function, which also has an replacement form.  If the units are changed, the numerical value is scaled accordingly.
"difftime"对象的单位,可以提取units功能,这也有一个替代的形式。如果单位发生了改变,相应地调整数值。

The as.double method returns the numeric value expressed in the specified units.  Using  units = "auto" means the units of the object.
as.double方法返回在指定的单位表示的数值。使用units = "auto"意味着该对象的单位。

The format method simply formats the numeric value and appends the units as a text string.
format方法简单格式的数值和附加的单位作为一个文本字符串。

The default behaviour when time1 or time2 was a "POSIXlt" object changed in R 2.12.0: previously such objects were regarded as in the timezone given by tz which defaulted to the current timezone.
时的默认行为time1或time2是"POSIXlt"对象,在2.12.0ŕ改变:以前这样的对象时区tz这拖欠的当前时区。


参见----------See Also----------

DateTimeClasses.
DateTimeClasses。


举例----------Examples----------


(z <- Sys.time() - 3600)
Sys.time() - z                # just over 3600 seconds.[刚刚超过3600秒。]

## time interval between releases of R 1.2.2 and 1.2.3.[#之间的R 1.2.2和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)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 21:14 , Processed in 0.019022 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表