Related
library(data.table)
library(survival)
library(survminer)
library(dcurves)
I have df as follows
structure(list(PatientID = c(1001L, 1002L, 1003L, 1004L, 1006L,
1014L, 1015L, 1016L, 1018L, 1022L, 1024L, 1032L, 1040L, 1042L,
1049L, 1056L, 1059L, 1060L, 1066L, 1084L, 1087L, 1090L, 1093L,
1096L, 1097L, 1098L, 1099L, 1200L, 1205L, 1216L, 1221L, 1222L,
1225L, 1226L, 1233L, 1239L), TimeMonths = c(9L, 8L, 69L, 104L,
104L, 100L, 24L, 85L, 100L, 99L, 67L, 58L, 7L, 94L, 93L, 90L,
91L, 90L, 89L, 72L, 84L, 84L, 11L, 82L, 39L, 46L, 82L, 82L, 9L,
34L, 75L, 76L, 52L, 20L, 29L, 70L), Event = c(1L, 0L, 0L, 0L,
0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L
), P1 = c(0.1, 0.03, 0.02, 0.05, 0.01, 0.04, 0.03,
0.06, 0.02, 0.03, 0, 0, 0.11, 0.01, 0.03, 0, 0.01, 0.01, 0.01,
0, 0, 0, 0.05, 0.01, 0, 0, 0, 0, 0.04, 0, 0.07, 0.01, 0.01, 0,
0, 0), Age = c(88L, 49L, 60L, 46L, 50L, 60L, 38L, 74L, 39L, 65L,
80L, 35L, 54L, 40L, 54L, 55L, 60L, 38L, 64L, 74L, 71L, 57L, 55L,
49L, 42L, 30L, 63L, 46L, 47L, 58L, 34L, 72L, 50L, 60L, 73L, 51L
), Grade = c(2L, 2L, 2L, 3L, 3L, 1L, 2L, 2L, 2L, 1L, 2L, 1L,
3L, 1L, 3L, NA, 2L, 3L, 2L, 2L, 2L, NA, 2L, 2L, 2L, 2L, 2L, 1L,
2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L), Tsize = c(2.5, 6, 4, 4, 3.5,
1.8, 1.5, 1.5, 2, 3.5, 4, 2, 4.5, 3, 3, 2, 3, 1.5, 2.5, 5, 5,
3, 6, 3, 2.5, 5, 1.5, 2, 5.5, 5, 3, 6, 4, 3.5, 4, 5), LNstatus = c(0L,
1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L,
1L, 1L, 0L), Time = c(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5), Model1 = c(0.0754111003682264, 0.789025824308725, 0.0888669573431788,
0.162944690463524, 0.148205788806964, 0.0232412222825853, 0.335639290548721,
0.427877640015971, 0.0437151408243315, 0.340118759660636, 0.104749557872707,
0.191041558905319, 0.901494025297558, 0.0271621117477482, 0.134690848022469,
NA, 0.0681964605449713, 0.0799110215826685, 0.0617151301818596,
0.129265190806531, 0.760358458474655, NA, 0.805815477115913,
0.0622010539620427, 0.4275233016386, 0.632818820863808, 0.39812097019303,
0.0217733118415042, 0.118190758626649, 0.721016961718498, 0.449778991144841,
0.164102951793386, 0.857780996059435, 0.576334735175668, 0.668186510212559,
0.107238793230798), Model2 = c(0.444752330666943, 0.930853771862407,
0.0980811416950194, 0.311714208416219, 0.108779198079316, 0.0297296718406789,
0.255165235219636, 0.652922467522166, 0.0301952043412281, 0.405213119172736,
0.0800242041001141, 0.0767147984837693, 0.999999999862285, 0.0181219543140756,
0.14865830843794, NA, 0.0496630840467432, 0.0382325860289233,
0.0421016493675688, 0.113455005788149, 0.665969059849803, NA,
0.991966233874329, 0.0424861062828985, 0.206267128670341, 0.453591375821231,
0.180419209497713, 0.00979786791522574, 0.243955485600603, 0.596589087934302,
0.778048018064795, 0.211053490646643, 0.747102269303274, 0.37666971629859,
0.511588083962541, 0.0826035699229486)), class = "data.frame", row.names = c(NA,
-36L))
I tried following code to generate the dca
dca(Surv(Time, Event) ~ Model1 + Model2, data = dfs,
label = list(Model1 = "Model1", Model2 = "Model2"), time = 5, thresholds = 1:35 / 100) %>% plot(smooth = TRUE)
Now I want to display the values of y axis at a specific x value for Model1 and Model2. It's approximately 0.255 and 0.300 respectively
Expected output
I would like to perform a cox regression analysis with value_max_min as predictor, but according 2 groups peakand drop in the column peak_drop_status(to get 2 survival curves).
cox <- coxph(Surv(mace_months_date_vs_date_sample, mace) ~ value_max_min, data = df)
and to get the plot
fit <- survfit(Surv(mace_months_date_vs_date_sample, mace) ~ value_max_min,
data = df)
I thought about using the group_by or the slice functions?
Library used:
library(dplyr)
library(survival)
library(survminer)
Here is the console output:
structure(list(ID = c(136L, 136L, 200L, 200L, 146L, 146L, 153L,
153L, 137L, 137L, 214L, 214L, 85L, 85L, 96L, 96L, 172L, 172L,
182L, 182L, 87L, 87L, 93L, 93L, 210L, 210L, 69L, 69L, 132L, 132L,
68L, 68L, 74L, 74L, 9L, 9L, 159L, 159L, 7L, 7L, 154L, 154L, 94L,
94L, 113L, 113L, 124L, 124L, 131L, 131L, 143L, 143L, 151L, 151L,
213L, 213L, 225L, 225L, 160L, 160L, 226L, 226L, 133L, 133L, 105L,
105L, 119L, 119L, 156L, 156L, 208L, 208L, 117L, 117L, 227L, 227L,
97L, 97L, 221L, 221L, 187L, 187L, 155L, 155L, 189L, 189L, 219L,
219L, 178L, 178L, 181L, 181L, 184L, 184L, 165L, 165L, 233L, 233L,
180L, 180L, 192L, 192L, 79L, 79L, 183L, 183L, 139L, 139L, 199L,
199L, 81L, 81L, 162L, 162L, 104L, 104L, 237L, 237L, 128L, 128L,
73L, 73L, 229L, 229L, 138L, 138L, 218L, 218L, 95L, 95L, 110L,
110L, 190L, 190L, 72L, 72L, 127L, 127L, 164L, 164L, 111L, 111L,
194L, 194L, 216L, 216L, 188L, 188L, 71L, 71L, 67L, 67L, 88L,
88L, 123L, 123L, 173L, 173L, 223L, 223L, 152L, 152L, 238L, 238L,
63L, 63L, 10L, 10L, 75L, 75L, 109L, 109L, 197L, 197L, 193L, 193L,
89L, 89L, 106L, 106L, 205L, 205L, 125L, 125L, 121L, 121L, 100L,
100L, 234L, 234L, 6L, 6L, 211L, 211L, 228L, 228L, 175L, 175L,
84L, 84L, 191L, 191L, 243L, 243L, 115L, 115L, 220L, 220L, 242L,
242L, 2L, 2L, 222L, 222L, 203L, 203L, 201L, 201L, 224L, 224L,
4L, 4L, 102L, 102L, 76L, 76L, 239L, 239L, 231L, 231L, 195L, 195L,
134L, 134L, 171L, 171L, 83L, 83L, 217L, 217L, 5L, 5L, 141L, 141L,
3L, 3L, 112L, 112L, 235L, 235L, 185L, 185L, 103L, 103L, 120L,
120L, 207L, 207L, 166L, 166L, 174L, 174L, 116L, 116L, 8L, 8L,
140L, 140L, 14L, 14L, 27L, 27L, 30L, 30L, 23L, 23L, 54L, 54L,
13L, 13L, 16L, 16L, 39L, 39L, 44L, 44L, 42L, 42L, 51L, 51L, 245L,
245L, 59L, 59L, 28L, 28L, 45L, 45L, 34L, 34L, 49L, 49L, 43L,
43L, 24L, 24L, 19L, 19L, 12L, 12L, 41L, 41L, 47L, 47L, 32L, 32L,
50L, 50L, 31L, 31L, 18L, 18L, 15L, 15L, 60L, 60L, 52L, 52L, 21L,
21L, 29L, 29L, 38L, 38L, 55L, 55L, 33L, 33L, 56L, 56L, 244L,
244L, 36L, 36L, 20L, 20L, 17L, 17L, 57L, 57L, 35L, 35L, 22L,
22L, 26L, 26L, 25L, 25L, 37L, 37L, 58L, 58L, 61L, 61L), age = c(49L,
49L, 77L, 77L, 75L, 75L, 75L, 75L, 63L, 63L, 60L, 60L, 72L, 72L,
51L, 51L, 50L, 50L, 35L, 35L, 48L, 48L, 44L, 44L, 79L, 79L, 67L,
67L, 57L, 57L, 58L, 58L, 46L, 46L, 57L, 57L, 59L, 59L, 71L, 71L,
65L, 65L, 56L, 56L, 28L, 28L, 65L, 65L, 41L, 41L, 76L, 76L, 63L,
63L, 66L, 66L, 69L, 69L, 37L, 37L, 52L, 52L, 47L, 47L, 63L, 63L,
41L, 41L, 79L, 79L, 42L, 42L, 69L, 69L, 76L, 76L, 68L, 68L, 66L,
66L, 59L, 59L, 64L, 64L, 72L, 72L, 65L, 65L, 75L, 75L, 56L, 56L,
80L, 80L, 68L, 68L, 58L, 58L, 61L, 61L, 59L, 59L, 68L, 68L, 60L,
60L, 39L, 39L, 63L, 63L, 52L, 52L, 82L, 82L, 63L, 63L, 49L, 49L,
59L, 59L, 61L, 61L, 64L, 64L, 63L, 63L, 66L, 66L, 68L, 68L, 54L,
54L, 73L, 73L, 54L, 54L, 46L, 46L, 75L, 75L, 72L, 72L, 64L, 64L,
69L, 69L, 68L, 68L, 59L, 59L, 52L, 52L, 65L, 65L, 51L, 51L, 48L,
48L, 63L, 63L, 52L, 52L, 56L, 56L, 67L, 67L, 68L, 68L, 47L, 47L,
75L, 75L, 76L, 76L, 63L, 63L, 73L, 73L, 48L, 48L, 68L, 68L, 48L,
48L, NA, NA, 74L, 74L, 37L, 37L, 60L, 60L, 54L, 54L, 55L, 55L,
61L, 61L, 79L, 79L, 67L, 67L, 57L, 57L, 51L, 51L, 67L, 67L, 68L,
68L, 51L, 51L, 53L, 53L, 51L, 51L, 62L, 62L, 60L, 60L, 71L, 71L,
58L, 58L, 52L, 52L, 72L, 72L, 73L, 73L, 76L, 76L, 81L, 81L, 48L,
48L, 65L, 65L, 57L, 57L, 51L, 51L, 56L, 56L, 66L, 66L, 46L, 46L,
78L, 78L, 76L, 76L, 81L, 81L, 71L, 71L, 46L, 46L, 51L, 51L, 73L,
73L, 66L, 66L, 59L, 59L, 77L, 77L, 74L, 74L, 28L, 28L, 73L, 73L,
54L, 54L, 59L, 59L, 53L, 53L, 57L, 57L, 54L, 54L, 52L, 52L, 38L,
38L, 73L, 73L, 62L, 62L, 61L, 61L, 76L, 76L, 51L, 51L, 51L, 51L,
54L, 54L, 59L, 59L, 47L, 47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1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mace_months_date_vs_date_sample = c(61L,
61L, 62L, 62L, 21L, 21L, 1L, 1L, 47L, 47L, 3L, 3L, 61L, 61L,
31L, 31L, 2L, 2L, 44L, 44L, 46L, 46L, 43L, 43L, 61L, 61L,
3L, 3L, 4L, 4L, 62L, 62L, 60L, 60L, 49L, 49L, 48L, 48L, 43L,
43L, 46L, 46L, 45L, 45L, 62L, 62L, 4L, 4L, 61L, 61L, 47L,
47L, 62L, 62L, 5L, 5L, 48L, 48L, 59L, 59L, 32L, 32L, 59L,
59L, 4L, 4L, 63L, 63L, 8L, 8L, 4L, 4L, 49L, 49L, 1L, 1L,
7L, 7L, 45L, 45L, 45L, 45L, 1L, 1L, 1L, 1L, 62L, 62L, 62L,
62L, 45L, 45L, 1L, 1L, 61L, 61L, 46L, 46L, 55L, 55L, 44L,
44L, 45L, 45L, 1L, 1L, 58L, 58L, 27L, 27L, 47L, 47L, 48L,
48L, 25L, 25L, 55L, 55L, 50L, 50L, 44L, 44L, 63L, 63L, 50L,
50L, 10L, 10L, 23L, 23L, 47L, 47L, 19L, 19L, 48L, 48L, 62L,
62L, 62L, 62L, 1L, 1L, 15L, 15L, 47L, 47L, 61L, 61L, 45L,
45L, 46L, 46L, 47L, 47L, 49L, 49L, 1L, 1L, 46L, 46L, 48L,
48L, 45L, 45L, 15L, 15L, 55L, 55L, 1L, 1L, 62L, 62L, 55L,
55L, 46L, 46L, 2L, 2L, 46L, 46L, 46L, 46L, 63L, 63L, 43L,
43L, 16L, 16L, 55L, 55L, 1L, 1L, 55L, 55L, 8L, 8L, 46L, 46L,
46L, 46L, 19L, 19L, 48L, 48L, 50L, 50L, 48L, 48L, 41L, 41L,
50L, 50L, 4L, 4L, 62L, 62L, 62L, 62L, 17L, 17L, 25L, 25L,
48L, 48L, 48L, 48L, 3L, 3L, 1L, 1L, 53L, 53L, 46L, 46L, 46L,
46L, 51L, 51L, 59L, 59L, 55L, 55L, 59L, 59L, 55L, 55L, 1L,
1L, 46L, 46L, 43L, 43L, 1L, 1L, 5L, 5L, 46L, 46L, 10L, 10L,
11L, 11L, 16L, 16L, 55L, 55L, 3L, 3L, 6L, 6L, 71L, 71L, 68L,
68L, 72L, 72L, 71L, 71L, 69L, 69L, 73L, 73L, 74L, 74L, 30L,
30L, 69L, 69L, 1L, 1L, 11L, 11L, 79L, 79L, 71L, 71L, 73L,
73L, 13L, 13L, 28L, 28L, 74L, 74L, 77L, 77L, 78L, 78L, 71L,
71L, 73L, 73L, 69L, 69L, 73L, 73L, 70L, 70L, 72L, 72L, 69L,
69L, 43L, 43L, 76L, 76L, 74L, 74L, 75L, 75L, 77L, 77L, 78L,
78L, 70L, 70L, 69L, 69L, 70L, 70L, 60L, 60L, 5L, 5L, 5L,
5L, 77L, 77L, 74L, 74L, 77L, 77L, 77L, 77L, 77L, 77L, 73L,
73L, 74L, 74L, 76L, 76L, 76L, 76L), trop = c(262L, 262L,
NA, NA, 1454L, 1454L, 663L, 663L, 2107L, 2107L, 86115L, 86115L,
24L, 24L, 3004L, 3004L, 9352L, 9352L, NA, NA, 1247L, 1247L,
NA, NA, 2888L, 2888L, NA, NA, 8421L, 8421L, NA, NA, NA, NA,
251L, 251L, 1211L, 1211L, NA, NA, 54592L, 54592L, 1241L,
1241L, 8669L, 8669L, 5204L, 5204L, 751L, 751L, 2840L, 2840L,
250L, 250L, NA, NA, NA, NA, 1411L, 1411L, 3789L, 3789L, 1675L,
1675L, 1557L, 1557L, 440L, 440L, NA, NA, 6979L, 6979L, 6155L,
6155L, 5110L, 5110L, 87355L, 87355L, 90L, 90L, 2234L, 2234L,
10000L, 10000L, NA, NA, 843L, 843L, 950L, 950L, 372L, 372L,
NA, NA, NA, NA, NA, NA, 6212L, 6212L, 871L, 871L, 776L, 776L,
24160L, 24160L, NA, NA, 9951L, 9951L, 3598L, 3598L, 2040L,
2040L, NA, NA, 6581L, 6581L, 349L, 349L, 11L, 11L, 6694L,
6694L, 63L, 63L, 15543L, 15543L, NA, NA, 33017L, 33017L,
2483L, 2483L, NA, NA, 961L, 961L, 1470L, 1470L, 2380L, 2380L,
11135L, 11135L, 1730L, 1730L, NA, NA, 11450L, 11450L, 769L,
769L, 16720L, 16720L, 57L, 57L, NA, NA, 4281L, 4281L, NA,
NA, 1258L, 1258L, NA, NA, 4299L, 4299L, 13374L, 13374L, NA,
NA, 2844L, 2844L, 1753L, 1753L, NA, NA, 5256L, 5256L, 3624L,
3624L, NA, NA, 21876L, 21876L, 8903L, 8903L, 844L, 844L,
5654L, 5654L, 3569L, 3569L, 45649L, 45649L, NA, NA, NA, NA,
4927L, 4927L, NA, NA, 2177L, 2177L, 5247L, 5247L, 50000L,
50000L, 438L, 438L, 1480L, 1480L, 50L, 50L, NA, NA, NA, NA,
27L, 27L, 2956L, 2956L, NA, NA, 3000L, 3000L, NA, NA, 6630L,
6630L, 1911L, 1911L, NA, NA, 2797L, 2797L, 6672L, 6672L,
1627L, 1627L, 123L, 123L, 7671L, 7671L, NA, NA, NA, NA, 2340L,
2340L, 10014L, 10014L, 7860L, 7860L, 67927L, 67927L, NA,
NA, NA, NA, 2413L, 2413L, 1035L, 1035L, 40273L, 40273L, 7120L,
7120L, 6440L, 6440L, 3340L, 3340L, 8450L, 8450L, 1500L, 1500L,
1970L, 1970L, 180L, 180L, 990L, 990L, 2600L, 2600L, 1800L,
1800L, 5280L, 5280L, 83L, 83L, 160L, 160L, 40L, 40L, 3710L,
3710L, 400L, 400L, NA, NA, 2100L, 2100L, 2390L, 2390L, 9320L,
9320L, 6020L, 6020L, 320L, 320L, 1420L, 1420L, 1710L, 1710L,
15300L, 15300L, 6490L, 6490L, 6390L, 6390L, 6300L, 6300L,
470L, 470L, 1740L, 1740L, 3600L, 3600L, NA, NA, 3930L, 3930L,
NA, NA, 2260L, 2260L, 1360L, 1360L, 846L, 846L, 15940L, 15940L,
NA, NA, 840L, 840L, 5010L, 5010L, NA, NA, 5330L, 5330L, 500L,
500L, 1080L, 1080L, NA, NA, NA, NA, 4470L, 4470L), egfr = c(90L,
90L, 48L, 48L, 65L, 65L, 35L, 35L, 84L, 84L, 90L, 90L, 64L,
64L, 61L, 61L, 86L, 86L, 56L, 56L, 90L, 90L, 62L, 62L, 75L,
75L, 56L, 56L, 86L, 86L, 90L, 90L, 89L, 89L, 84L, 84L, 86L,
86L, 65L, 65L, 86L, 86L, 61L, 61L, 90L, 90L, 73L, 73L, 61L,
61L, 77L, 77L, 60L, 60L, 58L, 58L, 80L, 80L, 58L, 58L, 90L,
90L, 64L, 64L, 68L, 68L, 90L, 90L, 61L, 61L, 80L, 80L, 90L,
90L, 36L, 36L, 90L, 90L, 90L, 90L, 59L, 59L, 90L, 90L, 77L,
77L, 64L, 64L, 52L, 52L, 90L, 90L, 33L, 33L, 90L, 90L, 90L,
90L, 90L, 90L, 90L, 90L, 90L, 90L, 69L, 69L, 90L, 90L, 46L,
46L, 90L, 90L, 75L, 75L, 54L, 54L, 90L, 90L, 54L, 54L, 90L,
90L, 82L, 82L, 49L, 49L, 35L, 35L, 90L, 90L, 66L, 66L, 90L,
90L, 86L, 86L, 90L, 90L, 45L, 45L, 72L, 72L, 68L, 68L, 51L,
51L, 90L, 90L, 90L, 90L, 90L, 90L, 58L, 58L, 84L, 84L, 42L,
42L, 90L, 90L, 86L, 86L, 90L, 90L, 90L, 90L, 90L, 90L, 87L,
87L, 67L, 67L, 51L, 51L, 81L, 81L, 74L, 74L, 63L, 63L, 90L,
90L, 56L, 56L, 87L, 87L, 84L, 84L, 78L, 78L, 63L, 63L, 63L,
63L, 63L, 63L, 67L, 67L, 64L, 64L, 68L, 68L, 78L, 78L, 68L,
68L, 90L, 90L, 69L, 69L, 90L, 90L, 90L, 90L, 75L, 75L, 85L,
85L, 85L, 85L, 52L, 52L, 69L, 69L, 90L, 90L, 76L, 76L, 90L,
90L, 54L, 54L, 86L, 86L, 90L, 90L, 61L, 61L, 72L, 72L, 76L,
76L, 69L, 69L, 85L, 85L, 86L, 86L, 42L, 42L, 72L, 72L, 71L,
71L, 58L, 58L, 68L, 68L, 86L, 86L, 75L, 75L, 84L, 84L, 63L,
63L, 63L, 63L, 78L, 78L, 90L, 90L, 48L, 48L, 55L, 55L, 81L,
81L, 87L, 87L, 99L, 99L, 77L, 77L, 56L, 56L, 69L, 69L, 66L,
66L, 67L, 67L, 85L, 85L, 90L, 90L, 65L, 65L, 68L, 68L, 76L,
76L, 84L, 84L, 90L, 90L, 59L, 59L, 88L, 88L, 79L, 79L, 85L,
85L, 90L, 90L, 90L, 90L, 77L, 77L, 90L, 90L, 49L, 49L, 62L,
62L, 71L, 71L, 87L, 87L, 51L, 51L, 90L, 90L, 90L, 90L, 79L,
79L, 90L, 90L, 90L, 90L, 52L, 52L, 75L, 75L, 71L, 71L, 68L,
68L, 83L, 83L, 88L, 88L, 51L, 51L, 87L, 87L, 99L, 99L, 78L,
78L, 90L, 90L), dm = c(0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L,
1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0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1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L,
1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L,
1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L,
1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L,
1L, 1L), peak_drop_status = c("max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val", "max_val", "min_val", "max_val", "min_val", "max_val",
"min_val"), value_max_min = c(NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 308.408676147461, -283.636077880859,
NA, NA, 208.791275024414, -5.3211898803711, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, -14.9628820419311, -218.279922485352, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -15.319938659668,
-279.422790527344, 248.09851074219, -30.822647094727, 116.716430664065,
-8.8325366973877, NA, NA, 10.0856704711914, -29.1057052612305,
179.8525390625, -10.1883692741394, 130.585632324218, -39.6044845581057,
32.883270263672, -5.3593330383301, -17.5934886932374, -821.989379882808,
375.086456298828, -5.7297992706299, NA, NA, NA, NA, NA, NA,
419.108337402341, -1.28273773193359, 55.87646484375, -17.770830154419,
NA, NA, 44.05969238281, -6.7603330612182, 36.9793767929077,
-58.77816772461, 47.6982421875, -48.2563076019287, 180.041305541992,
-3.5863590240479, 19.503479003907, -66.49755859375, NA, NA,
33.036499023438, -3.0688781738281, 83.0613746643061, -562.289733886719,
-5.5973930358887, -162.939453124998, 18.5003929138184, -95.700927734375,
164.985534667969, 9.7361946105957, 27.7907447814941, -69.5900268554681,
159.863708496094, -22.477741241455, -21.2021789550781, -372.002563476562,
153.190795898438, 5.9852733612061, 15.9482421875, -32.590072631836,
243.90209960937, -24.0595645904541, 131.392028808594, -5.5808029174805,
192.978088378906, -56.510217666626, 104.543823242188, -173.209777832031,
NA, NA, 174.83570098877, -69.742797851558, 12.743041992187,
-502.216308593755, 28.5669360160827, -388.549621582031, -15.8679084777832,
-308.033813476562, -12.657926082611, -133.534645795822, -0.800338745117202,
-170.645233154297, -8.9742355346679, -44.6486473083496, 3.6423645019532,
-0.407896041870121, 163.853607177735, -13.0253372192383,
327.035522460937, -3.5568542480469, 336.011077880859, -9.2046012878418
)), row.names = c(NA, -364L), class = c("tbl_df", "tbl",
"data.frame"))
Thank you,
To do a stratified Cox model, you would specify strata(var) in your model formula as follows:
library("survival")
library("survminer")
library("dplyr")
cox <- coxph(
Surv(mace_months_date_vs_date_sample, mace) ~ value_max_min + strata(peak_drop_status),
data = df
)
Your survfit isn't going to be very useful by the way, as you're supplying a numeric variable it's fitting a KM curve to every unique value of value_max_min. So you get a whole bunch of non-informative Kaplan-Meier curves:
fit <- survfit(
Surv(mace_months_date_vs_date_sample, mace) ~ value_max_min,
data = df
)
plot(fit)
It might be better for visualisation purposes to split your data into groups based on quantiles of the predictor:
med <- median(df$value_max_min, na.rm=TRUE)
fit <- survfit(
Surv(mace_months_date_vs_date_sample, mace) ~ (value_max_min > med),
data = df
)
plot(fit)
When I try to run log(x) on a variable in my dataset I get the error:
Error in oldat$gdp16 + 1 : non-numeric argument to binary operator
At first I thought that the reason is that these particular variables have NA's so I decided to deal with this problem like so:
oldat$gdp16[oldat$gdp16 == "#N/A"] <- "NA"
oldat$gdp16LOG <- log(oldat$gdp16 + 1, na.rm=TRUE)
This did not solve the problem.
Please find the excerpt of the data as an example below. The variable that fails the log transform is gdp16:
structure(list(gdp16 = c("19469", "159049", "554861", "10546",
"1208039", "390800", "37868", "11839", "32153", "47723", "467546",
"15649", "1793989", "53241", "32218", "1535768", "250036", "11190993",
"280091", "51339", "NA", "20154", "195305", "306900", "72343",
"98614", "332928", "5010", "23338", "73001", "4671", "238678",
"2465134", "14014", "14378", "3477796", "192691", "1056", "68664",
"320881", "125817", "20304", "2274230", "932256", "418977", "304819",
"317748", "1859384", "36375", "14057", "4949273", "137278", "70875",
"6715", "110912", "6813", "27572", "42773", "296536", "12232",
"1076912", "6796", "11183", "4374", "103606", "777228", "189286",
"404653", "7607", "1414804", "371075", "57821", "304889", "27424",
"471400", "205184", "105035", "152452", "187806", "1284728",
"644936", "38300", "309764", "89769", "44709", "295763", "1411042",
"1237255", "95584", "514460", "668745", "NA", "525608", "6952",
"411755", "4389", "22320", "42063", "863722", "24079", "93270",
"357045", "2650850", "18624475", "67068", "236", "205276", "16620"
), pop16 = c(34656L, 40606L, 43847L, 2925L, 24211L, 8737L, 9758L,
391L, 1425L, 9502L, 11331L, 2250L, 207653L, 7128L, 23439L, 36265L,
17910L, 1378665L, 48653L, 4174L, 11476L, 1170L, 10566L, 5728L,
10649L, 16385L, 95689L, 4955L, 1316L, 102403L, 899L, 5495L, 66860L,
1980L, 3719L, 82349L, 10776L, 107L, 16582L, 7337L, 9814L, 335L,
1324171L, 261115L, 80277L, 4755L, 8546L, 60627L, 23696L, 2881L,
126995L, 17794L, 48462L, 1816L, 4053L, 6080L, 1960L, 2868L, 31187L,
1263L, 127540L, 3552L, 3027L, 622L, 35277L, 17030L, 4693L, 185990L,
20673L, 51246L, 5235L, 4034L, 103320L, 6725L, 37970L, 10325L,
3407L, 2570L, 19702L, 144342L, 32276L, 7058L, 5607L, 5431L, 2065L,
56015L, 25369L, 46484L, 39579L, 9923L, 8373L, 18430L, 22465L,
8735L, 68864L, 7606L, 1365L, 11403L, 79512L, 41488L, 45005L,
9270L, 65596L, 323406L, 31848L, 31568L, 94569L, 16150L), gold16 = c(0L,
0L, 3L, 1L, 8L, 0L, 1L, 1L, 1L, 1L, 2L, 0L, 7L, 0L, 0L, 4L, 0L,
26L, 3L, 5L, 5L, 0L, 1L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L,
10L, 0L, 2L, 17L, 3L, 0L, 0L, 0L, 8L, 0L, 0L, 1L, 3L, 0L, 0L,
8L, 1L, 6L, 12L, 3L, 6L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 8L, 4L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 2L, 0L, 1L, 0L,
1L, 19L, 0L, 2L, 1L, 2L, 1L, 2L, 9L, 7L, 0L, 2L, 3L, 0L, 1L,
1L, 2L, 0L, 0L, 0L, 1L, 0L, 2L, 0L, 27L, 46L, 4L, 0L, 1L, 0L),
tot16 = c(0L, 2L, 4L, 4L, 29L, 1L, 18L, 2L, 2L, 9L, 6L, 0L,
19L, 3L, 0L, 22L, 0L, 70L, 8L, 10L, 11L, 0L, 10L, 15L, 1L,
0L, 3L, 0L, 1L, 8L, 1L, 1L, 42L, 0L, 7L, 42L, 6L, 1L, 0L,
0L, 15L, 0L, 2L, 3L, 8L, 2L, 2L, 28L, 2L, 11L, 41L, 18L,
13L, 1L, 0L, 0L, 0L, 4L, 5L, 0L, 5L, 0L, 2L, 0L, 1L, 19L,
18L, 1L, 1L, 7L, 4L, 0L, 1L, 0L, 11L, 1L, 1L, 1L, 4L, 55L,
0L, 8L, 1L, 4L, 4L, 10L, 21L, 17L, 0L, 11L, 7L, 0L, 3L, 1L,
6L, 0L, 1L, 3L, 8L, 0L, 11L, 1L, 67L, 121L, 13L, 3L, 2L,
0L), altitude = c(1790, 1, 10.5, 989, 605, 170, -28, 2, 6,
198, 76, 983, 1079, 580, 726, 74, 521, 44, 2625, 130, 4,
170, 244, 0, 0, 2850, 22, 2325, 37, 2355, 0, 25, 34, 0, 451,
34, 153, 25, 1529, 100, 102, 15, 210, 3, 1189, 8, 754, 14,
217, 53, 17, 338, 1795, 0, 5, 771, 8, 124, 60, 134, 2240,
80, 1350, 61, 53, -2, 10, 777, 207, 6, 12, 0, 7, 54, 93,
15, 3, 13, 70, 124, 624, 116, 0, 131, 281, 1271, 33, 667,
377, 15, 542, 691, 5, 789, 1, 63, 0, 0, 938, 1190, 168, 13,
14, 2, 459, 909, 25, 1483), athletes16 = c(3L, 64L, 215L,
31L, 420L, 72L, 56L, 29L, 33L, 120L, 104L, 12L, 462L, 50L,
24L, 310L, 42L, 392L, 143L, 85L, 117L, 15L, 104L, 119L, 26L,
37L, 121L, 12L, 46L, 37L, 53L, 54L, 393L, 6L, 40L, 418L,
92L, 7L, 21L, 37L, 154L, 8L, 112L, 28L, 63L, 76L, 47L, 309L,
12L, 56L, 336L, 101L, 79L, 8L, 0L, 19L, 32L, 67L, 32L, 2L,
123L, 23L, 43L, 35L, 48L, 237L, 195L, 71L, 6L, 31L, 62L,
10L, 13L, 11L, 234L, 90L, 40L, 37L, 95L, 285L, 10L, 103L,
25L, 52L, 63L, 135L, 135L, 307L, 6L, 151L, 103L, 7L, 57L,
7L, 54L, 5L, 28L, 61L, 100L, 21L, 204L, 12L, 360L, 555L,
70L, 86L, 22L, 30L)), class = "data.frame", row.names = c(NA,
-108L))
Your gdp16 variable is of class character. You cannot add a number to character. You need to convert your variable to the numeric type (and perhaps substitute NAs):
df$gdp16 <- as.numeric(df$gdp16)
You need to replace the "NA" with an actual NA, and do as.numeric:
oldat$gdp16LOG = log(as.numeric(replace(oldat$gdp16,oldat$gdp16=="NA",NA)))
You can just do as.numeric(oldat$gdp16) . It will return some error messages because any other string that is not numeric will be converted to NA..
I have a case where I only get TP, FP, FN and TN for every single data point (one example). In total, I have 24 examples (data points) with these 4 measures. I use 2 different methods and compute TP, FP, FN and TN for each example (data point). Now, I want to compare the performance of these 2 different methods by plotting a ROC curve. I have calculated TPR (y-axis) and FPR (x-axis) and plot them using ggplot2 (see image link) but I don't know how can I fit the curves on these data points so that they look like classical/traditional ROC curve plots. SO that I can also compute the auROC curve.
Can somebody guide me how to do it? Thank you.
plot using ggplot:
ggplot(data, aes(x=FPR, y=TPR)) + geom_point(aes(shape=Class, colour = Class), size=1.5) + scale_shape(solid = FALSE) + theme_update(plot.title=element_text(hjust=0.5)) + xlim(0,1) + xlab("False Positive Rate (FPR)") + ylab("True Positive Rate (TPR)")
Here is the dput of my data:
> dput(data)
structure(list(Class = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Epi",
"GE"), class = "factor"), TP = c(94L, 127L, 58L, 76L, 5L, 6L,
34L, 47L, 14L, 20L, 113L, 136L, 32L, 36L, 78L, 102L, 51L, 58L,
49L, 50L, 111L, 120L, 174L, 184L, 151L, 172L, 189L, 226L, 36L,
40L, 252L, 271L, 2L, 4L, 7L, 42L, 41L, 82L, 0L, 15L, 45L, 53L,
11L, 16L, 24L, 35L, 3L, 10L, 28L, 34L), FP = c(46L, 389L, 3L,
254L, 3L, 7L, 13L, 57L, 7L, 88L, 55L, 220L, 21L, 87L, 23L, 245L,
11L, 190L, 20L, 77L, 45L, 168L, 86L, 391L, 34L, 238L, 88L, 367L,
56L, 193L, 119L, 455L, 3L, 27L, 5L, 30L, 67L, 247L, 0L, 30L,
4L, 65L, 7L, 77L, 55L, 176L, 5L, 33L, 15L, 66L), FN = c(33L,
0L, 18L, 0L, 1L, 0L, 13L, 0L, 6L, 0L, 23L, 0L, 4L, 0L, 24L, 0L,
7L, 0L, 1L, 0L, 9L, 0L, 10L, 0L, 21L, 0L, 37L, 0L, 4L, 0L, 19L,
0L, 5L, 3L, 35L, 0L, 41L, 0L, 15L, 0L, 8L, 0L, 6L, 1L, 14L, 3L,
7L, 0L, 6L, 0L), TN = c(488L, 179L, 373L, 125L, 10L, 6L, 75L,
32L, 119L, 38L, 247L, 83L, 97L, 37L, 400L, 179L, 295L, 132L,
107L, 51L, 200L, 109L, 441L, 140L, 331L, 157L, 419L, 177L, 180L,
45L, 567L, 237L, 35L, 11L, 88L, 91L, 222L, 90L, 0L, 29L, 116L,
56L, 105L, 36L, 217L, 99L, 55L, 28L, 82L, 32L), TPR = c(0.74,
1, 0.76, 1, 0.83, 1, 0.72, 1, 0.7, 1, 0.83, 1, 0.89, 1, 0.76,
1, 0.88, 1, 0.98, 1, 0.92, 1, 0.95, 1, 0.88, 1, 0.84, 1, 0.9,
1, 0.93, 1, 0.29, 0.57, 0.17, 1, 0.5, 1, 0, 1, 0.85, 1, 0.65,
0.94, 0.63, 0.92, 0.3, 1, 0.82, 1), FPR = c(0.09, 0.68, 0.01,
0.67, 0.23, 0.54, 0.15, 0.64, 0.06, 0.7, 0.18, 0.73, 0.18, 0.7,
0.05, 0.58, 0.04, 0.59, 0.16, 0.6, 0.18, 0.61, 0.16, 0.74, 0.09,
0.6, 0.17, 0.67, 0.24, 0.81, 0.17, 0.66, 0.08, 0.71, 0.05, 0.25,
0.23, 0.73, NA, 0.51, 0.03, 0.54, 0.06, 0.68, 0.2, 0.64, 0.08,
0.54, 0.15, 0.67)), .Names = c("Class", "TP", "FP", "FN", "TN",
"TPR", "FPR"), class = "data.frame", row.names = c(NA, -50L))
EDIT:
This is how the header of data looks like:
> head(data)
Class TP FP FN TN TPR FPR
1 Epi 94 46 33 488 0.74 0.09
2 GE 127 389 0 179 1.00 0.68
3 Epi 58 3 18 373 0.76 0.01
4 GE 76 254 0 125 1.00 0.67
5 Epi 5 3 1 10 0.83 0.23
6 GE 6 7 0 6 1.00 0.54
I will explain the first 2 rows, the same explantation applies to the rest of them. I used 2 different methods (named Epi and GE) to calculate number of TP, FP, FN and TN in my predictions about 1 example ( represented in plot by 1 data point). Then I calculate TPR and FPR from them. Similarly, the same 2 methods I applied on rest of the 23 examples and this entire dataframe gives me the value of TP, FP, FN and TN for each method in every example (24 datapoints - 1 data point representing one example and its TPR/FPR rate calculated by one method i.e. either GE or Epi).
Starting R with a bare-bone
l#np350v5c:~$ R --vanilla
> search()
[1] ".GlobalEnv" "package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:methods" "Autoloads" "package:base"
.. this is a dump of data (emergency accesses hours in a northern Italy hospital) which gave a strange (to me) behaviour:
times <- structure(list(sec = c(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, 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, 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, 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, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 14L, 54L, 28L, 11L, 32L, 17L, 51L, 40L, 17L, 47L, 21L, 57L,
59L, 34L, 45L, 15L, 10L, 25L, 27L, 31L, 5L, 34L, 5L, 36L, 16L,
2L, 20L, 0L, 24L, 1L, 54L, 59L, 28L, 24L, 24L, 19L, 26L, 1L,
48L, 0L, 10L, 18L, 43L, 38L, 24L, 21L, 37L, 36L, 54L, 11L, 27L,
29L, 34L, 32L, 33L, 43L, 40L, 53L, 56L, 48L, 47L, 54L, 11L, 37L,
14L, 46L, 30L, 54L, 0L, 38L, 27L, 57L, 21L, 31L, 21L, 37L, 17L,
41L, 21L, 14L, 33L, 33L, 31L, 6L, 30L, 48L, 49L, 26L, 9L, 0L,
19L, 45L, 5L, 9L, 29L, 15L, 34L, 48L, 20L, 25L, 1L, 49L, 48L,
46L, 47L, 18L, 48L, 35L, 56L, 24L, 41L, 13L, 37L, 53L, 57L, 11L,
9L, 43L, 30L, 11L, 55L, 56L, 12L, 35L, 14L, 48L, 22L, 44L, 25L,
51L, 51L, 27L, 58L, 23L, 17L, 42L, 21L, 54L, 59L, 40L, 37L, 43L,
15L, 12L, 22L, 15L, 55L, 7L, 21L, 59L, 34L, 38L, 15L, 8L, 57L,
49L, 6L, 1L, 51L, 46L, 49L, 20L, 46L, 56L, 32L, 36L, 56L, 47L,
58L, 23L, 14L, 56L, 4L, 44L, 25L, 44L, 22L, 21L, 36L, 35L, 58L,
27L, 22L, 44L, 16L, 5L, 34L, 46L, 52L, 18L, 0L, 32L, 49L, 3L,
16L, 53L, 57L, 58L, 35L, 21L, 32L, 57L, 7L, 20L, 29L, 26L, 48L,
53L, 9L, 59L, 58L, 30L, 57L, 34L, 6L, 29L, 57L, 10L, 25L, 15L,
26L, 29L, 20L, 24L, 36L, 54L, 46L, 24L, 14L, 10L, 48L, 22L, 17L,
39L, 59L, 33L, 12L, 0L, 29L, 36L, 31L, 57L, 38L, 10L, 29L, 42L,
36L, 16L, 2L, 21L, 35L, 4L, 16L, 33L, 35L, 14L, 37L, 25L, 51L,
12L, 45L, 15L, 7L, 33L, 42L, 28L, 19L, 40L, 5L, 39L, 13L, 23L,
47L, 31L, 7L, 12L, 8L, 7L, 24L, 37L, 51L, 49L, 11L, 0L, 23L,
30L, 37L, 48L, 26L, 42L, 33L, 8L, 17L, 4L, 51L, 26L, 48L, 17L,
43L, 35L, 35L, 27L, 27L, 47L, 17L, 24L, 43L, 55L, 20L, 54L, 38L,
58L, 2L, 37L, 26L, 3L, 25L, 18L, 0L, 58L, 57L, 12L, 10L, 51L,
37L, 23L, 57L, 14L, 7L, 22L, 50L, 14L, 24L, 27L, 42L, 53L, 6L,
21L, 56L, 17L, 4L, 6L, 30L, 47L, 42L, 20L, 17L, 0L, 35L, 59L,
46L, 50L, 16L, 15L, 42L, 26L, 36L, 8L, 35L, 2L, 59L, 12L, 14L,
58L, 3L, 0L, 37L, 36L, 23L, 29L, 45L, 44L, 32L, 25L, 1L, 50L,
17L, 56L, 58L, 53L, 35L, 17L, 14L, 38L, 27L, 27L, 8L, 14L, 7L,
24L, 13L, 42L, 21L, 12L, 38L, 24L, 30L, 27L, 55L, 23L, 31L, 43L,
22L, 47L, 50L, 27L, 56L, 22L, 54L, 23L, 46L, 17L, 30L, 41L, 54L,
41L, 51L, 44L, 34L, 42L, 3L, 57L, 9L, 51L, 54L, 58L, 53L, 58L,
4L, 12L, 12L, 35L, 55L, 5L, 4L, 15L, 56L, 14L, 48L, 57L, 13L,
19L, 25L, 24L, 24L, 2L, 54L), hour = c(-3, -4, -3, -2, -4, -1,
-5, -4, -5, -5, -5, -4, -3, -2, -4, -2, -2, -4, -4, -1, -2, -5,
-5, -2, -2, -2, -5, -1, -1, -4, -3, -4, -4, -3, -4, -3, -1, -2,
-2, -1, -2, -5, -5, -3, -2, -2, -3, -3, -4, -1, -4, -3, -4, -2,
-5, -2, -4, -5, -4, -2, -5, -1, -5, -3, -2, -1, -3, -5, -1, -3,
-5, -1, -5, -1, -3, -1, -2, -5, -3, -1, -5, -1, -1, -3, -5, -1,
-2, -4, -4, -5, -3, -5, -4, -1, -5, -2, -5, -3, -5, -5, -2, -1,
-5, -3, -5, -3, -2, -4, -3, -1, -1, -2, -3, -1, -4, -3, -4, -5,
-1, -5, -3, -3, -1, -3, -3, -4, -4, -2, -5, -5, -1, -3, -5, -2,
-3, -2, -1, -5, -3, -5, -1, -1, -1, -3, -3, -5, -1, -2, -4, -2,
-4, -1, -4, -5, -1, -5, -1, -1, -4, -2, -5, -5, -3, -1, -5, -3,
-4, -5, -4, -5, -3, -5, -5, -5, -2, -5, -3, -5, -3, -4, -4, -5,
-5, -1, -4, -4, -1, -3, -1, -3, -3, -4, -2, -2, -4, -3, -1, -4,
-5, -3, -1, -3, -4, -3, -5, -1, -3, -5, -4, -5, -2, -4, -1, -3,
-5, -2, -5, -3, -4, -2, -5, -4, -1, -5, -3, -5, -1, -2, -2, -4,
-3, -4, -2, -4, -3, -4, -2, -5, -1, -1, -2, -1, -3, -5, -1, -1,
-2, -4, -4, -5, -3, -3, -3, -4, -4, -4, -4, -3, -4, -2, -5, -4,
-1, -4, -5, -4, -3, -3, -5, -2, -3, -1, -4, -1, -5, -2, -1, -1,
-4, -3, -2, -5, -4, -3, -4, -1, -3, -4, -5, -3, -2, -4, -1, -4,
-4, -2, -5, -3, -5, -1, -3, -4, -2, -1, -2, -3, -5, -3, -1, -1,
-3, -4, -4, -2, -2, -1, -2, -1, -4, -2, -5, -2, -1, -3, -5, -1,
-5, -3, -3, -5, -2, -1, -1, -4, -5, -5, -4, -1, -3, -5, -2, -4,
-1, -2, -4, -5, -5, -1, -5, -5, -4, -2, -5, -2, -3, -2, -2, -2,
-3, -2, -4, -4, -5, -1, -2, -5, -3, -1, -1, -4, -1, -5, -3, -5,
-4, -2, -4, -3, -4, -4, -3, -2, -2, -5, -2, -1, -1, -1, -3, -5,
-4, -5, -1, -1, -3, -2, -4, -2, -2, -1, -2, -4, -3, -5, -2, -1,
-4, -4, -1, -4, -2, -3, -2, -1, -5, -5, -4, -2, -1, -5, -3, -3,
-4, -5, -3, -4, -1, -3, -2, -2, -2, -4, -1, -2, -2, -2, -5, -1,
-4, -2, -4, -2, -5, -4, -2, -3, -2, -1, -1, -1, -3, -2, -5, -3,
-5, -2, -1), mday = c(24L, 30L, 13L, 17L, 11L, 17L, 1L, 26L,
21L, 1L, 9L, 6L, 7L, 17L, 17L, 4L, 24L, 23L, 31L, 2L, 22L, 19L,
12L, 17L, 26L, 13L, 12L, 26L, 14L, 20L, 22L, 14L, 26L, 29L, 7L,
16L, 19L, 10L, 19L, 17L, 15L, 22L, 4L, 22L, 6L, 22L, 6L, 24L,
18L, 11L, 13L, 26L, 5L, 2L, 1L, 12L, 15L, 21L, 22L, 24L, 25L,
18L, 4L, 18L, 28L, 4L, 21L, 25L, 18L, 4L, 8L, 10L, 21L, 11L,
11L, 20L, 23L, 14L, 16L, 2L, 31L, 3L, 21L, 3L, 1L, 13L, 26L,
20L, 17L, 4L, 3L, 13L, 10L, 23L, 16L, 1L, 28L, 27L, 16L, 29L,
6L, 15L, 6L, 14L, 4L, 17L, 15L, 4L, 19L, 26L, 20L, 22L, 24L,
1L, 16L, 18L, 12L, 21L, 26L, 11L, 30L, 19L, 26L, 4L, 3L, 2L,
26L, 30L, 14L, 16L, 21L, 20L, 29L, 26L, 17L, 23L, 8L, 19L, 23L,
14L, 14L, 5L, 28L, 6L, 15L, 13L, 8L, 6L, 1L, 2L, 3L, 5L, 16L,
17L, 3L, 23L, 20L, 27L, 28L, 1L, 31L, 26L, 14L, 30L, 22L, 9L,
31L, 5L, 19L, 9L, 27L, 26L, 24L, 12L, 27L, 20L, 9L, 4L, 9L, 4L,
18L, 9L, 13L, 10L, 23L, 27L, 11L, 21L, 6L, 6L, 6L, 9L, 23L, 14L,
27L, 23L, 17L, 19L, 29L, 16L, 18L, 4L, 5L, 29L, 14L, 16L, 19L,
25L, 14L, 16L, 27L, 12L, 11L, 26L, 2L, 17L, 1L, 20L, 2L, 3L,
5L, 7L, 27L, 27L, 17L, 6L, 4L, 11L, 5L, 15L, 13L, 19L, 1L, 29L,
18L, 29L, 17L, 23L, 31L, 26L, 19L, 17L, 14L, 21L, 17L, 13L, 5L,
13L, 4L, 27L, 13L, 18L, 4L, 24L, 23L, 21L, 25L, 25L, 2L, 24L,
25L, 28L, 6L, 10L, 15L, 9L, 7L, 8L, 9L, 22L, 17L, 11L, 15L, 24L,
14L, 23L, 18L, 28L, 3L, 20L, 25L, 5L, 17L, 21L, 24L, 21L, 24L,
3L, 31L, 21L, 18L, 27L, 30L, 25L, 13L, 8L, 21L, 16L, 22L, 24L,
3L, 16L, 4L, 22L, 15L, 30L, 2L, 16L, 28L, 24L, 26L, 20L, 9L,
3L, 3L, 4L, 11L, 5L, 30L, 19L, 24L, 3L, 24L, 5L, 14L, 4L, 23L,
18L, 7L, 16L, 24L, 3L, 27L, 4L, 30L, 22L, 28L, 17L, 25L, 3L,
19L, 18L, 26L, 8L, 24L, 18L, 17L, 6L, 17L, 25L, 6L, 23L, 14L,
4L, 5L, 15L, 5L, 4L, 19L, 4L, 7L, 24L, 28L, 23L, 28L, 9L, 7L,
27L, 26L, 25L, 4L, 19L, 24L, 18L, 18L, 7L, 16L, 11L, 10L, 21L,
6L, 30L, 15L, 1L, 16L, 16L, 21L, 17L, 8L, 19L, 1L, 23L, 10L,
18L, 2L, 8L, 20L, 28L, 25L, 28L, 25L, 23L, 5L, 4L, 31L, 2L, 21L,
30L, 1L, 4L, 18L, 8L, 25L, 1L, 25L, 2L, 5L, 20L, 2L, 17L, 5L,
5L, 30L, 30L, 17L, 5L, 18L, 21L, 24L, 20L, 26L, 31L, 15L, 30L,
16L, 6L, 18L, 28L, 7L, 25L, 24L, 7L, 23L, 9L, 8L, 25L, 11L, 20L,
19L, 24L, 5L, 5L, 26L, 26L, 7L, 29L, 22L), mon = c(10L, 4L, 7L,
7L, 4L, 10L, 11L, 5L, 5L, 5L, 1L, 5L, 10L, 9L, 1L, 6L, 7L, 7L,
0L, 5L, 7L, 10L, 6L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, 7L, 8L, 8L, 10L, 1L, 7L, 2L,
9L, 8L, 2L, 5L, 0L, 10L, 5L, 6L, 2L, 10L, 1L, 8L, 7L, 0L, 1L,
3L, 9L, 3L, 6L, 4L, 10L, 0L, 3L, 5L, 4L, 10L, 9L, 7L, 4L, 3L,
0L, 3L, 3L, 1L, 9L, 5L, 3L, 3L, 8L, 11L, 10L, 4L, 11L, 0L, 7L,
1L, 0L, 4L, 2L, 2L, 0L, 0L, 7L, 4L, 4L, 10L, 8L, 3L, 8L, 11L,
8L, 0L, 0L, 6L, 6L, 1L, 0L, 3L, 4L, 2L, 9L, 1L, 6L, 4L, 3L, 1L,
0L, 0L, 11L, 1L, 4L, 3L, 7L, 10L, 2L, 1L, 0L, 0L, 5L, 4L, 8L,
10L, 7L, 10L, 8L, 8L, 1L, 8L, 11L, 8L, 10L, 7L, 11L, 4L, 8L,
1L, 10L, 3L, 10L, 5L, 10L, 7L, 9L, 9L, 2L, 10L, 0L, 9L, 4L, 7L,
7L, 11L, 1L, 11L, 1L, 1L, 4L, 2L, 3L, 3L, 5L, 10L, 0L, 7L, 9L,
7L, 10L, 10L, 4L, 2L, 0L, 0L, 1L, 7L, 8L, 6L, 9L, 9L, 11L, 4L,
6L, 8L, 9L, 0L, 8L, 6L, 4L, 6L, 7L, 4L, 0L, 0L, 9L, 1L, 4L, 0L,
1L, 8L, 1L, 3L, 7L), year = c(112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L,
112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L, 112L
), wday = c(6L, 3L, 1L, 5L, 5L, 6L, 6L, 2L, 4L, 5L, 4L, 3L, 3L,
3L, 5L, 3L, 5L, 4L, 2L, 6L, 3L, 1L, 4L, 4L, 6L, 5L, 3L, 1L, 5L,
5L, 0L, 2L, 2L, 0L, 5L, 0L, 6L, 0L, 1L, 1L, 0L, 2L, 6L, 3L, 4L,
0L, 2L, 1L, 3L, 6L, 0L, 4L, 5L, 1L, 2L, 1L, 0L, 0L, 5L, 5L, 2L,
6L, 3L, 3L, 1L, 3L, 5L, 2L, 6L, 5L, 6L, 3L, 4L, 5L, 3L, 5L, 4L,
6L, 4L, 5L, 1L, 4L, 2L, 5L, 1L, 6L, 5L, 2L, 2L, 6L, 3L, 5L, 0L,
0L, 1L, 4L, 3L, 5L, 0L, 0L, 6L, 4L, 5L, 5L, 1L, 5L, 3L, 2L, 0L,
5L, 2L, 6L, 5L, 0L, 4L, 0L, 1L, 5L, 3L, 2L, 0L, 6L, 0L, 3L, 2L,
6L, 4L, 1L, 6L, 6L, 2L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, 5L, 6L, 6L, 6L, 4L, 6L, 3L, 5L, 5L, 2L,
2L, 4L, 0L, 0L, 5L, 4L, 4L, 4L, 4L, 2L, 0L, 3L, 2L, 6L, 3L, 5L,
4L, 3L, 1L, 2L, 2L, 1L, 5L, 5L, 0L, 5L, 5L, 4L, 1L, 3L, 6L, 5L,
1L, 3L, 2L, 1L, 2L, 0L, 0L, 3L, 5L, 0L, 3L, 1L, 6L, 3L, 1L, 3L,
5L, 3L, 5L, 5L, 5L, 6L, 4L, 0L, 3L, 2L, 0L, 3L), yday = c(328L,
150L, 225L, 229L, 131L, 321L, 335L, 177L, 172L, 152L, 39L, 157L,
311L, 290L, 47L, 185L, 236L, 235L, 30L, 153L, 234L, 323L, 193L,
137L, 146L, 194L, 346L, 330L, 257L, 110L, 203L, 44L, 177L, 210L,
341L, 259L, 139L, 161L, 78L, 260L, 14L, 142L, 34L, 52L, 340L,
21L, 65L, 358L, 199L, 41L, 133L, 207L, 278L, 183L, 121L, 316L,
14L, 294L, 173L, 54L, 268L, 48L, 185L, 199L, 148L, 94L, 264L,
359L, 230L, 124L, 342L, 283L, 172L, 131L, 192L, 19L, 235L, 13L,
46L, 306L, 365L, 123L, 233L, 215L, 274L, 286L, 299L, 324L, 107L,
34L, 276L, 103L, 161L, 357L, 197L, 305L, 332L, 26L, 350L, 119L,
279L, 319L, 187L, 257L, 155L, 229L, 227L, 247L, 49L, 299L, 79L,
356L, 54L, 182L, 228L, 322L, 71L, 264L, 269L, 254L, 273L, 139L,
56L, 3L, 2L, 153L, 207L, 211L, 104L, 167L, 233L, 232L, 363L,
207L, 47L, 266L, 312L, 292L, 82L, 318L, 318L, 4L, 118L, 279L,
288L, 225L, 220L, 36L, 274L, 61L, 62L, 4L, 228L, 16L, 215L, 327L,
232L, 178L, 240L, 152L, 243L, 360L, 134L, 334L, 234L, 343L, 212L,
339L, 323L, 190L, 86L, 207L, 23L, 224L, 331L, 79L, 282L, 124L,
39L, 63L, 230L, 252L, 103L, 314L, 327L, 270L, 10L, 294L, 96L,
340L, 187L, 343L, 174L, 73L, 270L, 82L, 351L, 353L, 59L, 259L,
48L, 185L, 248L, 149L, 134L, 106L, 49L, 55L, 257L, 320L, 239L,
102L, 254L, 177L, 122L, 47L, 213L, 232L, 183L, 62L, 186L, 280L,
208L, 361L, 260L, 187L, 308L, 70L, 35L, 227L, 194L, 323L, 152L,
149L, 48L, 28L, 47L, 22L, 365L, 85L, 200L, 290L, 348L, 355L,
321L, 347L, 217L, 256L, 124L, 208L, 286L, 138L, 247L, 297L, 296L,
325L, 329L, 115L, 214L, 297L, 145L, 271L, 65L, 314L, 319L, 129L,
97L, 38L, 282L, 234L, 290L, 101L, 166L, 23L, 257L, 296L, 230L,
271L, 154L, 232L, 268L, 248L, 321L, 51L, 236L, 80L, 297L, 246L,
90L, 172L, 17L, 331L, 181L, 206L, 72L, 312L, 51L, 259L, 234L,
23L, 33L, 106L, 277L, 112L, 196L, 150L, 306L, 15L, 118L, 175L,
146L, 324L, 282L, 215L, 123L, 94L, 10L, 95L, 120L, 49L, 297L,
154L, 114L, 95L, 257L, 338L, 327L, 138L, 341L, 15L, 236L, 33L,
26L, 124L, 89L, 81L, 27L, 16L, 237L, 123L, 139L, 322L, 269L,
98L, 267L, 352L, 260L, 5L, 16L, 206L, 187L, 53L, 13L, 94L, 125L,
74L, 278L, 34L, 200L, 124L, 97L, 54L, 27L, 22L, 362L, 39L, 127L,
117L, 238L, 329L, 63L, 49L, 23L, 17L, 169L, 127L, 259L, 315L,
222L, 325L, 249L, 273L, 45L, 244L, 350L, 259L, 325L, 229L, 342L,
139L, 244L, 53L, 314L, 108L, 306L, 159L, 324L, 240L, 298L, 301L,
84L, 327L, 4L, 277L, 151L, 214L, 233L, 364L, 31L, 338L, 48L,
38L, 145L, 60L, 115L, 92L, 156L, 324L, 1L, 229L, 278L, 217L,
334L, 334L, 137L, 64L, 17L, 20L, 54L, 232L, 269L, 212L, 288L,
303L, 350L, 126L, 199L, 271L, 280L, 24L, 267L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L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L,
0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L,
0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L,
1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 1L,
0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L,
0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L,
0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 1L)), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXlt", "POSIXt"))
Then, trying to extract hours in different ways
df <- data.frame(times,
with.dollar = times$hour,
with.format = as.numeric(format(times, "%H"))
)
head(df)
and my results are
times with.dollar with.format
1 2012-11-23 21:05:00 -3 21
2 2012-05-29 20:43:00 -4 20
3 2012-08-12 21:02:00 -3 21
4 2012-08-16 22:47:00 -2 22
5 2012-05-10 20:15:00 -4 20
6 2012-11-16 23:18:00 -1 23
Another test (not in a data.frame... simple vectors)
> any(times$hour == as.numeric(format(times, "%H")))
[1] FALSE
With times$hour it seems to be counting hours starting from the next days in some cases (all of the cases here reported).
Could you reproduce that? any idea why?
Looking at ?POSIXlt this could be a bug because not all hours are within 0:23 range.
If so, for the moment it would be safer to use format rather $ for POSIXlt vector
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 0.3
year 2014
month 03
day 06
svn rev 65126
language R
version.string R version 3.0.3 (2014-03-06)
nickname Warm Puppy