I have a large dataset organised in choice groups see below. Each choice
represents a separate occasion with 1 product chosen out of the 6 offered.
Â
Â
Â
   Â
+-------------------------------------------------------------------------------------------------+
    | dn  obs  choice     acid  br            Â
   date      cdate  situat~n  mth  year  set |
   Â
|-------------------------------------------------------------------------------------------------|
 1. | 4    1       0    LOSEC   1         Â
         .          .               .  Â
  .    1 |
 2. | 4    1       0   NEXIUM   2          Â
        .          .               .  Â
  .    1 |
 3. | 4    1       0   PARIET   3          Â
        .          .               .   Â
 .    1 |
 4. | 4    1       0  PROTIUM   4          Â
        .          .               .   Â
 .    1 |
 5. | 4    1       0   ZANTAC   5          Â
        .          .               .   Â
 .    1 |
   Â
|-------------------------------------------------------------------------------------------------|
 6. | 4    1       1    ZOTON   6  23aug2000
01:00:00Â Â 23aug2000Â Â Â Â Â Â Â Â NSÂ Â 487Â Â 2000Â Â Â Â 1 |
 7. | 4    2       0    LOSEC   1         Â
         .          .               .  Â
  .    2 |
 8. | 4    2       0   NEXIUM   2          Â
        .          .               .  Â
  .    2 |
 9. | 4    2       1   PARIET   3  25sep2000
01:00:00Â Â 25sep2000Â Â Â Â Â Â Â Â Â LÂ Â 488Â Â 2000Â Â Â Â 2 |
10. |Â 4Â Â Â Â 2Â Â Â Â Â Â Â 0Â Â PROTIUMÂ Â Â 4Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    2 |
   Â
|-------------------------------------------------------------------------------------------------|
11. |Â 4Â Â Â Â 2Â Â Â Â Â Â Â 0Â Â Â ZANTACÂ Â Â 5Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    2 |
12. |Â 4Â Â Â Â 2Â Â Â Â Â Â Â 0Â Â Â Â ZOTONÂ Â Â 6Â Â Â Â Â Â Â Â Â Â Â
        .          .               .   Â
 .    2 |
13. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 0Â Â Â Â LOSECÂ Â Â 1Â Â Â Â Â Â Â Â Â Â Â
        .          .               .   Â
 .    3 |
14. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 0Â Â Â NEXIUMÂ Â Â 2Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    3 |
15. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 0Â Â Â PARIETÂ Â Â 3Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    3 |
   Â
|-------------------------------------------------------------------------------------------------|
16. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 0Â Â PROTIUMÂ Â Â 4Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    3 |
17. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 0Â Â Â ZANTACÂ Â Â 5Â Â Â Â Â Â Â Â Â Â Â Â
       .          .               .    Â
.    3 |
18. |Â 4Â Â Â Â 3Â Â Â Â Â Â Â 1Â Â Â Â ZOTONÂ Â Â 6Â Â 20sep2000
00:00:00Â Â 20sep2000Â Â Â Â Â Â Â Â Â RÂ Â 488Â Â 2000Â Â Â Â 3 |
19. | Â 4Â Â Â Â 4Â Â Â Â Â Â Â 0Â Â Â Â LOSECÂ Â Â 1Â Â Â Â Â Â Â Â Â Â Â
        .          .               .   Â
 .    4 |
Â
I wish to fill in the missing values in each choice set â delineated by dn
(Doctor) obs (Observation number) and choices (1 to 6).
For each choice set one choice is chosen which contains full time information
for that choice set ie in set 1 choice 6 was chosen and
shows the month 487. The other 5 choices show mth as missing. I want to fill
these with the correct mth.
Â
Clearly on different occasions the date will differ but each choice set has
only one date.
Â
Is there a simple elegant way to do this in R?Â
Kind regards
Graham
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.