Description Usage Arguments Details Value Author(s) See Also Examples
The seq.count function counts the number of occurences of a given value in a channel. Currently a channel is represented as a set of column names of a data.frame and the corresponding data.frame.
1 2 3 4 5 6 7 8 9 10 11 |
x |
a |
value |
a |
sequence |
a |
origin |
a |
window.start |
a |
window.end |
a |
translate |
a |
verbose |
a |
quiet |
a |
Please take care that if you use a variable for translating windows for each individual, and this variable contains NA, the corresponding rows will be removed. In this case you will be alerted by a warning.
A data.frame. If verbose is FALSE the data.frame contains only one columns, named COUNT, corresponding to the count for each individual. If verbose is TRUE the data.frame will also contains columns helping to control how the count was performed: START, STOP, RANGE, TRANSLATE and the columns corresponding to the channel.
Emmanuel Rousseaux
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | # data.frame example
data.ex <- data.frame(
"id" = 1:7,
"age.2010" = c(5,3,0,1,4,NA,30),
"vuln.2000" = c(0,1,1,0,NA,1,1),
"vuln.2001" = c(0,0,1,0,NA,1,1),
"vuln.2002" = c(0,1,0,1,NA,0,0),
"vuln.2003" = c(0,0,0,1,NA,1,1),
"vuln.2004" = c(0,NA,1,1,NA,1,1),
"vuln.2005" = c(0,0,1,0,NA,0,1),
"vuln.2006" = c(0,0,1,0,NA,0,1),
"vuln.2007" = c(0,0,0,1,NA,1,1),
"vuln.2008" = c(0,0,1,1,NA,1,0),
"vuln.2009" = c(0,0,0,1,NA,1,0),
"vuln.2010" = c(0,0,1,1,NA,1,1)
)
data.ex
#### Example 0
# We count only in the year 2006
count0 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2006",
window.end = 1 # we take only 1 measure
)
count0
# Same example with the mode 'verbose' on
count0 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2006",
window.end = 1, # we take only 1 measure
verbose = TRUE
)
count0
#### Example 1
# We count between 2006 (included) and 2008 (included)
count1 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2006",
window.end = 3
)
count1
# Same example with the mode 'verbose' on
count1 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2006",
window.end = 3,
verbose = TRUE
)
count1
#### Example 2
# For each individual we count occurences of '1' when there where between 0 and 2 years (included)
count2 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2010", # as we have the age in 2010, we use vuln.2010 as origin
window.end = 3, # 0, 1 and 2 years
translate = c('left' = 'age.2010')
)
count2
# Same example with the mode 'verbose' on
count2 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2010", # as we have the age in 2010, we use vuln.2010 as origin
window.end = 3, # 0, 1 and 2 years
translate = c('left' = 'age.2010'),
verbose = TRUE
)
count2
#### Example 3
# For each individual we count occurences of '1' when there were 2 years
count3 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2010",
window.start = 2, # we start two values after origin: corresponding to 2 years old
window.end = 3, # and we stop three values after origin: we get only the value at 2 years
translate = c('left' = 'age.2010'),
verbose = TRUE
)
count3
#### Example 4
# For each individual we count occurences of '1' when there were betweeb 2 years and 5 years
count4 <- seq.count(
x = data.ex,
value = 1,
sequence = c("vuln.2000","vuln.2001","vuln.2002","vuln.2003","vuln.2004","vuln.2005","vuln.2006","vuln.2007","vuln.2008","vuln.2009","vuln.2010"),
origin = "vuln.2010",
window.start = 2, # we start two values after origin: corresponding to 2 years old
window.end = 6, # and we stop six values after origin: we get the count for the range [2-5]
translate = c('left' = 'age.2010'),
verbose = TRUE
)
count4
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.