std.time: Time standardize results

Description Usage Arguments Value References Examples

View source: R/tds.R

Description

Set results for a temporal evaluation to a timescale by trimming off time prior to the first onset and following the last offset time, and express the remaining times in terms of percentiles [0, 100].

Usage

1
2
std.time(X, trim.left = TRUE, trim.right = TRUE, scale = TRUE,
  missing = 0)

Arguments

X

vector (or data frame) of indicator data.

trim.left

Trim on the left? Default is TRUE.

trim.right

Trim on the right? Default is TRUE.

scale

Set to a [0, 1] scale? Default is TRUE.

missing

indicator for missing data; default is 0.

Value

out vector (or data frame) of trimmed and/or standardized indicator (0/1) data

References

Lenfant, F., Loret, C., Pineau, N., Hartmann, C., & Martin, N. (2009). Perception of oral food breakdown. The concept of sensory trajectory. Appetite, 52, 659-667.

Examples

 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
# vector - toy data example
x <- rep(c(rep(0,18), rep(1,18)), 2)
names(x) <- 1:72
x           # raw time
std.time(x) # standardized time

# data frame - toy data example
y <- data.frame(rbind(c(c(rep(0,18),
                           rep(1,18)),
                           rep(0, 4)),
                           c(rep(c(rep(0,9),
                           rep(1,9)), 2),
                           1, rep(0, 3)),
                           rep(0, 40)))
colnames(y) <- 1:40
y           # raw time
std.time(y) # standardized time

# time standardization using 'bars' data set
# only sample 1 will be done (for illustrative purposes)
eval1 <- unique(bars[bars$sample == 1, (1:3)])
bar1.std <- data.frame(unique(bars[bars$sample == 1, (1:4)]), matrix(0, ncol = 101))

for (e in 1:nrow(eval1)){
  bar1.std[bar1.std$assessor == eval1$assessor[e] &
             bar1.std$session == eval1$session[e] &
             bar1.std$sample == eval1$sample[e],
             -c(1:4)] <- std.time(bars[bars$assessor == eval1$assessor[e] &
                                         bars$session == eval1$session[e] &
                                         bars$sample == eval1$sample[e],
                                           -c(1:4)])
}
colnames(bar1.std)[5:ncol(bar1.std)] <- 0:100
head(bar1.std)

Example output

 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 
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1 
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 
 1  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 
 0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19 
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
 20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39 
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   0   0   0   0   0   0 
 40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59 
  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
 60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79 
  0   0   0   0   0   0   0   0   1   1   1   1   1   1   1   1   1   1   1   1 
 80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
100 
  1 
  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
1 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1
2 0 0 0 0 0 0 0 0 0  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0  0  0  0  1  1
3 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  30 31 32 33 34 35 36 37 38 39 40
1  1  1  1  1  1  1  1  0  0  0  0
2  1  1  1  1  1  1  1  1  0  0  0
3  0  0  0  0  0  0  0  0  0  0  0
  0 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
1 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
2 1 1 1 1 1 1 1 1 1 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
3 0 0 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  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
1  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
2  1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  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
1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
2  0  0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  0   0
2  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1   1
3  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0
   assessor session sample     attribute 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1         1       1      1 Grain Flavour 1 1 1 1 1 1 0 0 0 0  0  0  0  0  0  0
5         2       1      1 Grain Flavour 1 1 1 1 1 1 1 1 1 1  1  1  1  1  1  1
9         3       1      1 Grain Flavour 1 1 1 1 0 0 0 0 0 0  0  0  0  0  0  0
13        4       1      1 Grain Flavour 1 1 1 1 1 1 1 1 1 1  1  1  1  1  1  0
17        5       1      1 Grain Flavour 1 1 1 1 1 1 1 1 1 1  1  1  1  1  1  1
21        6       1      1 Grain Flavour 0 0 0 0 0 0 0 0 0 0  1  1  1  1  1  1
   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
1   0  0  1  1  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  0  0
5   1  1  1  1  1  1  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1
9   0  0  0  0  1  1  1  1  1  1  1  1  1  0  0  0  0  0  1  1  1  1  1  1  1
13  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1
17  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
21  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  0
   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
1   0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
5   1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
9   0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0
13  1  1  1  1  1  1  1  1  1  1  1  1  1  0  0  0  0  0  0  0  0  0  0  0  0
17  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
21  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
   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
1   1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
5   1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
9   0  0  0  0  1  1  1  1  0  0  0  0  0  0  0  0  0  0  0  1  1  1  1  1  1
13  0  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  0
17  0  0  0  0  0  0  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
21  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
   91 92 93 94 95 96 97 98 99 100
1   1  1  1  1  1  1  1  1  1   1
5   1  1  1  1  1  1  1  1  1   1
9   0  0  0  0  1  1  1  1  1   1
13  0  0  0  0  0  0  0  0  0   0
17  1  1  1  1  1  1  1  1  1   1
21  0  0  0  0  0  0  0  0  0   0

tempR documentation built on May 2, 2019, 9:33 a.m.