SCM

SCM Repository

[rmetrics] Annotation of /pkg/timeSeries/R/utils-head.R
ViewVC logotype

Annotation of /pkg/timeSeries/R/utils-head.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4213 - (view) (download)

1 : wuertz 4158 #
2 :     # This program is free software; you can redistribute it and/or modify
3 :     # it under the terms of the GNU General Public License as published by
4 :     # the Free Software Foundation; either version 2 of the License, or
5 :     # (at your option) any later version.
6 :     #
7 :     # This program is distributed in the hope that it will be useful,
8 :     # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 :     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 :     # GNU General Public License for more details.
11 :     #
12 :     # A copy of the GNU General Public License is available at
13 :     # ../../COPYING
14 :    
15 :    
16 :     ################################################################################
17 :     # METHOD: SUBSETTING METHODS ON DATA:
18 :     # head,timeSeries Returns the head of a 'timeSeries' object
19 :     # tail,timeSeries Returns the tail of a 'timeSeries' object
20 :     ################################################################################
21 :    
22 :    
23 : chalabi 4213 .head.timeSeries <- function(x, n = 6, recordIDs = FALSE, ...)
24 :     {
25 : wuertz 4158 # A function implemented by Diethelm Wuertz
26 :    
27 :     # Description:
28 :     # Returns the head of a 'timeSeries' object
29 :    
30 :     # Arguments:
31 :     # x - a 'timeSeries' object.
32 :    
33 :     # Value:
34 :     # Returns the head of an object of class 'timeSeries'.
35 :    
36 :     # FUNCTION:
37 :    
38 :     # Head:
39 :     if (recordIDs & dim(x)[1] == dim(x@recordIDs)[1])
40 :     cbind(head.matrix(x, n = n, ...), head(x@recordIDs, n = n, ...))
41 :     else
42 :     head.matrix(x, n = n, ...)
43 : chalabi 4213 }
44 : wuertz 4158
45 : chalabi 4213 setMethod("head", "timeSeries", function(x, n = 6, recordIDs = FALSE, ...)
46 :     .head.timeSeries(x, n, recordIDs, ...))
47 : wuertz 4158
48 :     # until UseMethod dispatches S4 methods in 'base' functions
49 : chalabi 4213 head.timeSeries <- function(x, ...) .head.timeSeries(x, ...)
50 : wuertz 4158
51 :    
52 :     # ------------------------------------------------------------------------------
53 :    
54 :    
55 : chalabi 4213 .tail.timeSeries <- function(x, n = 6, recordIDs = FALSE, ...)
56 : wuertz 4158 { # A function implemented by Diethelm Wuertz
57 :    
58 :     # Description:
59 :     # Returns the tail of a 'timeSeries' object
60 :    
61 :     # Arguments:
62 :     # x - a 'timeSeries' object.
63 :    
64 :     # Value:
65 :     # Returns the tail of an object of class 'timeSeries'.
66 :    
67 :     # FUNCTION:
68 :    
69 :     # Tail:
70 :     if (recordIDs & dim(x)[1] == dim(x@recordIDs)[1])
71 :     cbind(tail.matrix(x, n = n, addrownums = FALSE, ...),
72 :     tail(x@recordIDs, n = n, addrownums = FALSE, ...))
73 :     else
74 :     tail.matrix(x, n = n, addrownums = FALSE, ...)
75 : chalabi 4213 }
76 : wuertz 4158
77 : chalabi 4213 setMethod("tail", "timeSeries", function(x, n = 6, recordIDs = FALSE, ...)
78 :     .tail.timeSeries(x, n, recordIDs, ...))
79 : wuertz 4158
80 :     # until UseMethod dispatches S4 methods in 'base' functions
81 : chalabi 4213 tail.timeSeries <- function(x, ...) .tail.timeSeries(x, ...)
82 : wuertz 4158
83 :    
84 :     ################################################################################
85 :    

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge