-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFLCompMethods.R
More file actions
71 lines (66 loc) · 2.55 KB
/
FLCompMethods.R
File metadata and controls
71 lines (66 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#' @title year range
#' @description method to extract from \code{FLComp} objects the year range.
#' @param object a \code{FLComp} object
#' @return a \code{vector} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("rngyear", function(object, ...) standardGeneric("rngyear"))
setMethod("rngyear", "FLComp", function(object){
object@range[c("minyear","maxyear")]
})
#' @title year range replacement
#' @description method to replace \code{FLComp} object's year range.
#' @param object a \code{FLComp} object
#' @param value a \code{vector} with max and min year range
#' @return a \code{a4aM} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("rngyear<-", function(object,value) standardGeneric("rngyear<-"))
setReplaceMethod("rngyear", "FLComp", function(object, value){
object@range[c("minyear","maxyear")] <- value
object
})
#' @title age range
#' @description method to extract from \code{FLComp} objects the age range.
#' @param object a \code{FLComp} object
#' @return a \code{vector} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("rngage", function(object, ...) standardGeneric("rngage"))
setMethod("rngage", "FLComp", function(object){
object@range[c("min","max")]
})
#' @title age range replacement
#' @description method to replace \code{FLComp} object's age range.
#' @param object a \code{FLComp} object
#' @param value a \code{vector} with max and min age range
#' @return a \code{a4aM} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("rngage<-", function(object,value) standardGeneric("rngage<-"))
setReplaceMethod("rngage", "FLComp", function(object, value){
object@range[c("min","max")] <- value
object
})
#' @title year vector
#' @description method to extract from \code{FLComp} objects the vector of years.
#' @param object a \code{a4aM} object
#' @return a \code{vector} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("vecyear", function(object, ...) standardGeneric("vecyear"))
setMethod("vecyear", "FLComp", function(object){
rng <- object@range[c("minyear","maxyear")]
rng[1]:rng[2]
})
#' @title age vector
#' @description method to extract from \code{FLComp} objects the vector of ages.
#' @param object a \code{a4aM} object
#' @return a \code{vector} object
#' @author EJ \email{ernesto.jardim@@jrc.ec.europa.eu}
#' @export
setGeneric("vecage", function(object, ...) standardGeneric("vecage"))
setMethod("vecage", "FLComp", function(object){
rng <- object@range[c("min","max")]
rng[1]:rng[2]
})