Thanks in advance.
I am trying to add missing date values ββthat were not included in the observation period for three different individuals.
My data is as follows:
IndID Date Event Number Percent
1 P01 2011-03-04 1 2 0.390
2 P01 2011-03-11 1 2 0.975
3 P01 2011-03-13 0 9 0.795
4 P01 2011-03-14 0 10 0.516
5 P01 2011-03-15 0 1 0.117
6 P01 2011-03-17 0 7 0.093
IndID- a unique identifier ( P01, P03, P06). Date- This is obviously a date. Event- A binary variable indicating whether an event has occurred ( 0= no and 1= yes).
Columns Numberand Percenthave no direct value, but they need to save and thus to include here.
My sample data frame ( PostData) is given below using dput.
IndID Date - , . - 0 Event. (Number Percent) .
, - .
min(PostData$Date) max(PostData$Date). , merge for. , .
.
PostData <-structure(list(IndID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L), .Label = c("P01", "P02", "P03", "P05", "P06", "P07",
"P08", "P09", "P10", "P11", "P12", "P13"), class = "factor"),
Date = structure(c(1299196800, 1299801600, 1299974400, 1300060800,
1300147200, 1300320000, 1300406400, 1310083200, 1310169600,
1310515200, 1310774400, 1310947200, 1311033600, 1311292800,
1311552000, 1323129600, 1323388800, 1323648000, 1323993600,
1324080000, 1324166400, 1324339200, 1327622400, 1327795200,
1327881600), class = c("POSIXct", "POSIXt"), tzone = "GMT"),
Event = c(1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L,
0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L), Number = c(2L,
2L, 9L, 10L, 1L, 7L, 5L, 9L, 1L, 4L, 5L, 2L, 0L, 1L, 10L,
5L, 0L, 6L, 5L, 10L, 9L, 4L, 4L, 8L, 1L), Percent = c(0.39,
0.975, 0.795, 0.516, 0.117, 0.093, 0.528, 0.659, 0.308, 0.055,
0.185, 0.761, 0.132, 0.676, 0.368, 0.383, 0.272, 0.113, 0.974,
0.696, 0.941, 0.751, 0.758, 0.29, 0.15)), .Names = c("IndID",
"Date", "Event", "Number", "Percent"), row.names = c(NA, 25L),
class = "data.frame")