c.miTemporal {MIfuns} | R Documentation |
These functions support classes miTemporal, miTime, miDate, and miDateTime (and related functions). They are mostly S3 methods for base R generics.
## S3 method for class 'miTemporal': c(..., recursive = FALSE) ## S3 method for class 'miTemporal': x[..., drop = TRUE] ## S3 method for class 'miTemporal': x[...] <- value ## S3 method for class 'miTemporal': x[[..., drop = TRUE]] ## S3 method for class 'miTemporal': as.character(x, ...) as.chartime(x, ...) ## S3 method for class 'numeric': as.chartime(x, format, mark=TRUE,...) ## S3 method for class 'chartime': as.numeric(x, format,...) ## S3 method for class 'miTemporal': print(x, ...) ## S3 method for class 'miTemporal': seq(from, to, by = NULL, length.out = NULL, along.with = NULL, ...) subclass(x, class,...)
... |
arguments to c(), or passed to other functions |
recursive |
same meaning as for c() |
x |
object of class miTemporal |
drop |
same meaning as for '[' and '[[' |
value |
value to be assigned, as for '[<-' |
format |
input or output format describing character time (see strftime |
mark |
boolean: mark times with dangling seconds using '+' |
from |
as for seq.default |
to |
as for seq.default |
by |
as for seq.default |
length.out |
as for seq.default |
along.with |
as for seq.default |
class |
class to prepend to class attribute of x |
Normally you shouldn't need to worry about these functions. c() and the '[' variants exist just so that class information is not lost on invocation of the generic. as.character.miTemporal() and print.miTemporal() just call format(). 'chartime' variants are used internally by other functions. seq.miTemporal() requires 'from' and 'to', sets smart defaults for 'by' (if null), and preserves class information, relative to seq.default(). subclass() returns its first argument with 'class' prepended to its class list.
subclass |
see above |
print |
an invisible object with same class as x |
as.chartime |
generic: does not return |
as.chartime.numeric |
character (time) |
as.numeric.chartime |
numeric (seconds) |
as.character.miTemporal |
character (time) |
others |
object with same class as x |
Tim Bergsma
http://mifuns.googlecode.com
miTemporal
,
seq.default
,
strftime
,
#as.data.frame data.frame( dt=as.miDateTime(seq(from=0,by=86500,length.out=3)), d=as.miDate(seq(from=0,by=86400,length.out=3)), t=as.miTime(c(60,120,180)) ) # dt d t #1 01/01/1970 00:00 01/01/1970 00:01 #2 01/02/1970 00:01+ 01/02/1970 00:02 #3 01/03/1970 00:03+ 01/03/1970 00:03 #combine c(as.miTime(0),as.miTime(60)) # 00:00 00:01 c(as.miDate(0),as.miDate(86400)) # 01/01/1970 01/02/1970 c(as.miDateTime(0),as.miDateTime(86500)) # 01/01/1970 00:00 01/02/1970 00:01+ #subset as.miTime(c("08:00","09:00"))[2] # 09:00 as.miDate(c("2008-01-01","2008-01-04"))[2] # 01/04/2008 as.miDateTime(c("2008-01-01 12:00","2008-01-04 12:30"))[2] # 01/04/2008 12:30 #element selection as.miTime(c("08:00","09:00"))[[2]] # 09:00 as.miDate(c("2008-01-01","2008-01-04"))[[2]] # 01/04/2008 as.miDateTime(c("2008-01-01 12:00","2008-01-04 12:30"))[[2]] # 01/04/2008 12:30 #assignment a <- as.miTime(seq(60,300, by=60)) a#00:01 00:02 00:03 00:04 00:05 a[5] <- 60 a#00:01 00:02 00:03 00:04 00:01 a[3] <- NA a#00:01 00:02 NA 00:04 00:01 #identity as.miTime(as.miTime(0)) # 00:00 as.miDate(as.miDate(0)) # 01/01/1970 as.miDateTime(as.miDateTime(0)) # 01/01/1970 00:00