#Loading libraries: tidyverse , medicaldata (Install them first if not installed in your PC) You can check if the packages installed or not and if not installed, they will be istalled like thsi

if(!require(package name)){ install.packages(“package name”) library(somepackage) }

##installing packages##

packages = c(“dplyr”, “ggplot2”, “Publish”) #making list of package names

if(!require(packages)){ install.packages(packages)}

##Loading packages to R invironment

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(medicaldata)

##loading data file (Cytomegalovirsu) >>Show head >>Show structure of the data >>Change class of “diagnosis” to factor >>Save the diagnosis of class factor into a new column name called diagnosisf >>Use the mutate method to make diagnosisf

data("cytomegalovirus")
head(cytomegalovirus)
##   ID age sex race                    diagnosis diagnosis.type
## 1  1  61   1    0       acute myeloid leukemia              1
## 2  2  62   1    1         non-Hodgkin lymphoma              0
## 3  3  63   0    1         non-Hodgkin lymphoma              0
## 4  4  33   0    1             Hodgkin lymphoma              0
## 5  5  54   0    1 acute lymphoblastic leukemia              0
## 6  6  55   1    1                myelofibrosis              1
##   time.to.transplant prior.radiation prior.chemo prior.transplant recipient.cmv
## 1               5.16               0           2                0             1
## 2              79.05               1           3                0             0
## 3              35.58               0           4                0             1
## 4              33.02               1           4                0             1
## 5              11.40               0           5                0             1
## 6               2.43               0           0                0             1
##   donor.cmv donor.sex TNC.dose CD34.dose CD3.dose CD8.dose TBI.dose C1/C2 aKIRs
## 1         0         0    18.31      2.29     3.21     0.95      200     0     1
## 2         0         1     4.26      2.04       NA       NA      200     1     5
## 3         1         0     8.09      6.97     2.19     0.59      200     0     3
## 4         0         1    21.02      6.09     4.87     2.32      200     0     2
## 5         1         0    14.70      2.36     6.55     2.40      400     0     6
## 6         1         1     4.29      6.91     2.53     0.86      200     0     2
##   cmv time.to.cmv agvhd time.to.agvhd cgvhd time.to.cgvhd
## 1   1        3.91     1          3.55     0          6.28
## 2   0       65.12     0         65.12     0         65.12
## 3   0        3.75     0          3.75     0          3.75
## 4   0       48.49     1         28.55     1         10.45
## 5   0        4.37     1          2.79     0          4.37
## 6   1        4.53     1          3.88     0          6.87
str(cytomegalovirus)
## 'data.frame':    64 obs. of  26 variables:
##  $ ID                : num  1 2 3 4 5 6 7 8 9 10 ...
##  $ age               : num  61 62 63 33 54 55 67 51 44 59 ...
##  $ sex               : num  1 1 0 0 0 1 1 1 0 1 ...
##  $ race              : num  0 1 1 1 1 1 1 1 0 1 ...
##  $ diagnosis         : chr  "acute myeloid leukemia" "non-Hodgkin lymphoma" "non-Hodgkin lymphoma" "Hodgkin lymphoma" ...
##  $ diagnosis.type    : num  1 0 0 0 0 1 1 1 0 0 ...
##  $ time.to.transplant: num  5.16 79.05 35.58 33.02 11.4 ...
##  $ prior.radiation   : num  0 1 0 1 0 0 0 0 1 0 ...
##  $ prior.chemo       : num  2 3 4 4 5 0 2 0 3 2 ...
##  $ prior.transplant  : num  0 0 0 0 0 0 0 1 1 0 ...
##  $ recipient.cmv     : num  1 0 1 1 1 1 1 1 1 0 ...
##  $ donor.cmv         : num  0 0 1 0 1 1 1 1 1 0 ...
##  $ donor.sex         : num  0 1 0 1 0 1 1 0 1 0 ...
##  $ TNC.dose          : num  18.31 4.26 8.09 21.02 14.7 ...
##  $ CD34.dose         : num  2.29 2.04 6.97 6.09 2.36 6.91 3.66 3.9 7 2.52 ...
##  $ CD3.dose          : num  3.21 NA 2.19 4.87 6.55 2.53 3.66 7.27 2.59 2.52 ...
##  $ CD8.dose          : num  0.95 NA 0.59 2.32 2.4 0.86 0.17 1.95 NA 1.22 ...
##  $ TBI.dose          : num  200 200 200 200 400 200 400 400 200 400 ...
##  $ C1/C2             : num  0 1 0 0 0 0 0 0 1 1 ...
##  $ aKIRs             : num  1 5 3 2 6 2 1 2 2 4 ...
##  $ cmv               : num  1 0 0 0 0 1 0 0 1 0 ...
##  $ time.to.cmv       : num  3.91 65.12 3.75 48.49 4.37 ...
##  $ agvhd             : num  1 0 0 1 1 1 0 0 1 0 ...
##  $ time.to.agvhd     : num  3.55 65.12 3.75 28.55 2.79 ...
##  $ cgvhd             : num  0 0 0 1 0 0 0 0 1 1 ...
##  $ time.to.cgvhd     : num  6.28 65.12 3.75 10.45 4.37 ...
as.factor(cytomegalovirus$diagnosis)
##  [1] acute myeloid leukemia       non-Hodgkin lymphoma        
##  [3] non-Hodgkin lymphoma         Hodgkin lymphoma            
##  [5] acute lymphoblastic leukemia myelofibrosis               
##  [7] acute myeloid leukemia       acute myeloid leukemia      
##  [9] multiple myelomas            chronic lymphocytic leukemia
## [11] multiple myelomas            acute myeloid leukemia      
## [13] myelodysplastic syndrome     multiple myelomas           
## [15] myelodysplastic syndrome     non-Hodgkin lymphoma        
## [17] acute myeloid leukemia       myelodysplastic syndrome    
## [19] non-Hodgkin lymphoma         chronic lymphocytic leukemia
## [21] chronic myeloid leukemia     chronic myeloid leukemia    
## [23] myelodysplastic syndrome     myelofibrosis               
## [25] acute myeloid leukemia       renal cell carcinoma        
## [27] renal cell carcinoma         chronic myeloid leukemia    
## [29] myelodysplastic syndrome     chronic lymphocytic leukemia
## [31] multiple myelomas            non-Hodgkin lymphoma        
## [33] Hodgkin lymphoma             renal cell carcinoma        
## [35] non-Hodgkin lymphoma         chronic myeloid leukemia    
## [37] non-Hodgkin lymphoma         non-Hodgkin lymphoma        
## [39] chronic lymphocytic leukemia renal cell carcinoma        
## [41] multiple myelomas            myelodysplastic syndrome    
## [43] multiple myelomas            aplastic anemia             
## [45] Hodgkin lymphoma             myelodysplastic syndrome    
## [47] multiple myelomas            chronic lymphocytic leukemia
## [49] myelofibrosis                non-Hodgkin lymphoma        
## [51] acute myeloid leukemia       congenital anemia           
## [53] non-Hodgkin lymphoma         myelodysplastic syndrome    
## [55] acute myeloid leukemia       acute myeloid leukemia      
## [57] acute myeloid leukemia       myelofibrosis               
## [59] non-Hodgkin lymphoma         non-Hodgkin lymphoma        
## [61] acute myeloid leukemia       myelodysplastic syndrome    
## [63] myeloproliferative disorder  acute myeloid leukemia      
## 13 Levels: acute lymphoblastic leukemia ... renal cell carcinoma
mutate(cytomegalovirus, diagnosisf = as.factor(cytomegalovirus$diagnosis))
##    ID age sex race                    diagnosis diagnosis.type
## 1   1  61   1    0       acute myeloid leukemia              1
## 2   2  62   1    1         non-Hodgkin lymphoma              0
## 3   3  63   0    1         non-Hodgkin lymphoma              0
## 4   4  33   0    1             Hodgkin lymphoma              0
## 5   5  54   0    1 acute lymphoblastic leukemia              0
## 6   6  55   1    1                myelofibrosis              1
## 7   7  67   1    1       acute myeloid leukemia              1
## 8   8  51   1    1       acute myeloid leukemia              1
## 9   9  44   0    0            multiple myelomas              0
## 10 10  59   1    1 chronic lymphocytic leukemia              0
## 11 11  45   1    1            multiple myelomas              0
## 12 12  57   1    1       acute myeloid leukemia              1
## 13 13  52   0    1     myelodysplastic syndrome              1
## 14 14  38   0    1            multiple myelomas              0
## 15 15  35   1    1     myelodysplastic syndrome              1
## 16 16  61   0    1         non-Hodgkin lymphoma              0
## 17 17  62   0    1       acute myeloid leukemia              1
## 18 18  45   0    1     myelodysplastic syndrome              1
## 19 19  62   1    0         non-Hodgkin lymphoma              0
## 20 20  51   0    1 chronic lymphocytic leukemia              0
## 21 21  52   0    1     chronic myeloid leukemia              1
## 22 22  62   0    0     chronic myeloid leukemia              1
## 23 23  62   1    1     myelodysplastic syndrome              1
## 24 24  52   0    1                myelofibrosis              1
## 25 25  45   0    1       acute myeloid leukemia              1
## 26 26  48   1    1         renal cell carcinoma             NA
## 27 27  48   1    1         renal cell carcinoma             NA
## 28 28  57   1    1     chronic myeloid leukemia              1
## 29 29  60   0    1     myelodysplastic syndrome              1
## 30 30  48   0    0 chronic lymphocytic leukemia              0
## 31 31  49   1    1            multiple myelomas              0
## 32 32  58   1    1         non-Hodgkin lymphoma              0
## 33 33  36   1    1             Hodgkin lymphoma              0
## 34 34  29   0    1         renal cell carcinoma             NA
## 35 35  57   1    1         non-Hodgkin lymphoma              0
## 36 36  39   0    1     chronic myeloid leukemia              1
## 37 37  46   1    1         non-Hodgkin lymphoma              0
## 38 38  51   1    1         non-Hodgkin lymphoma              0
## 39 39  56   1    1 chronic lymphocytic leukemia              0
## 40 40  46   0    1         renal cell carcinoma             NA
## 41 41  36   0    0            multiple myelomas              0
## 42 42  62   0    1     myelodysplastic syndrome              1
## 43 43  60   0    1            multiple myelomas              0
## 44 44  36   1    1              aplastic anemia             NA
## 45 45  62   1    1             Hodgkin lymphoma              0
## 46 46  62   1    1     myelodysplastic syndrome              1
## 47 47  34   1    1            multiple myelomas              0
## 48 48  54   1    1 chronic lymphocytic leukemia              0
## 49 49  57   1    1                myelofibrosis              1
## 50 50  57   0    1         non-Hodgkin lymphoma              0
## 51 51  50   1    1       acute myeloid leukemia              1
## 52 52  42   1    1            congenital anemia             NA
## 53 53  55   0    1         non-Hodgkin lymphoma              0
## 54 54  64   0    1     myelodysplastic syndrome              1
## 55 55  61   1    1       acute myeloid leukemia              1
## 56 56  57   1    1       acute myeloid leukemia              1
## 57 57  61   0    1       acute myeloid leukemia              1
## 58 58  57   0    1                myelofibrosis              1
## 59 59  58   1    1         non-Hodgkin lymphoma              0
## 60 60  41   0    1         non-Hodgkin lymphoma              0
## 61 61  57   0    1       acute myeloid leukemia              1
## 62 62  61   1    1     myelodysplastic syndrome              1
## 63 63  50   1    1  myeloproliferative disorder              1
## 64 64  64   0    1       acute myeloid leukemia              1
##    time.to.transplant prior.radiation prior.chemo prior.transplant
## 1                5.16               0           2                0
## 2               79.05               1           3                0
## 3               35.58               0           4                0
## 4               33.02               1           4                0
## 5               11.40               0           5                0
## 6                2.43               0           0                0
## 7                9.59               0           2                0
## 8                  NA               0           0                1
## 9               43.43               1           3                1
## 10              92.71               0           2                0
## 11              39.00               1           3                1
## 12              17.84               0           2                0
## 13               4.53               0           3                1
## 14              21.32               1           3                1
## 15              16.33               1           0                1
## 16             162.40               0           5                0
## 17              13.70               0           2                0
## 18               8.71               0           4                1
## 19              76.09               0           7                0
## 20              30.98               0           2                0
## 21              14.23               0           1                0
## 22              10.35               0           1                0
## 23               4.53               0           0                0
## 24               5.45               0           0                0
## 25               9.66               0           3                0
## 26               3.65               0           0                0
## 27               6.90               0           1                0
## 28               3.19               0           0                0
## 29               8.67               0           1                0
## 30             136.87               0           4                0
## 31               4.07               0           1                0
## 32              18.79               0           3                1
## 33              27.76               1           5                1
## 34               5.19               0           1                0
## 35              19.42               0           2                0
## 36               9.92               0           2                0
## 37              12.88               0           2                0
## 38              99.42               1           4                0
## 39              88.57               0           4                0
## 40               8.48               1           1                0
## 41              11.70               0           2                1
## 42              13.04               0           0                0
## 43              14.00               0           2                1
## 44               1.84               0           1                0
## 45              43.89               0           5                0
## 46               7.82               0           1                0
## 47              14.62               0           2                1
## 48              18.33               0           2                0
## 49              13.70               0           1                0
## 50              46.82               0           3                0
## 51              30.39               0           3                0
## 52              24.34               0           0                0
## 53              10.74               0           2                0
## 54              10.97               0           1                0
## 55               2.53               0           2                0
## 56               4.50               0           1                0
## 57               4.01               0           2                0
## 58               5.68               0           0                0
## 59              70.74               1           8                0
## 60             151.59               1           5                0
## 61              33.54               0           1                0
## 62               8.94               0           1                0
## 63             173.83               0           1                0
## 64              24.44               0           2                0
##    recipient.cmv donor.cmv donor.sex TNC.dose CD34.dose CD3.dose CD8.dose
## 1              1         0         0    18.31      2.29     3.21     0.95
## 2              0         0         1     4.26      2.04       NA       NA
## 3              1         1         0     8.09      6.97     2.19     0.59
## 4              1         0         1    21.02      6.09     4.87     2.32
## 5              1         1         0    14.70      2.36     6.55     2.40
## 6              1         1         1     4.29      6.91     2.53     0.86
## 7              1         1         1     7.96      3.66     3.66     0.17
## 8              1         1         0    15.63      3.90     7.27     1.95
## 9              1         1         1     6.86      7.00     2.59       NA
## 10             0         0         0     7.54      2.52     2.52     1.22
## 11             0         1         1    13.55      7.00     5.23     2.48
## 12             0         1         0    11.67      7.00       NA       NA
## 13             1         1         0    14.25      4.06     6.56       NA
## 14             1         1         0     8.08      7.03     3.23       NA
## 15             0         1         1    12.45      7.00     3.62     1.74
## 16             1         1         0    12.58      3.46     3.08       NA
## 17             1         1         1     2.06      7.00     2.06       NA
## 18             0         0         1     9.76      5.76     5.76     1.19
## 19             1         1         0    16.50      7.00     8.18     3.05
## 20             1         0         0    11.30      6.87       NA       NA
## 21             0         0         1     8.38      7.04     2.78     0.93
## 22             1         1         0     8.10      6.92     8.10       NA
## 23             0         0         1     3.37      7.00     1.08       NA
## 24             0         1         0    11.99      6.11     4.34       NA
## 25             1         0         1    15.16      6.99     5.24     1.53
## 26             0         1         0     8.68      4.85     4.25       NA
## 27             1         1         1    15.25      3.58     3.97     1.13
## 28             1         1         1    11.71      3.13     3.98     2.11
## 29             1         1         1    10.62      6.58     3.92     1.40
## 30             0         1         1    14.58      7.03     3.30     1.07
## 31             0         1         0    10.97      5.80     4.43     1.57
## 32             0         0         1    10.35      4.51     4.00     1.46
## 33             0         0         0    17.87      3.04     4.44     2.01
## 34             0         0         0    12.94      6.74     3.91     1.55
## 35             0         0         1     5.09      7.33     2.48     0.47
## 36             1         1         0    14.87     12.51     5.99     1.59
## 37             1         1         1    14.34      7.21     5.48     2.96
## 38             0         0         1     6.90      6.42     1.74     0.68
## 39             1         0         1     2.85      2.90     1.50     0.27
## 40             1         1         0     7.29      6.92     3.58     1.29
## 41             1         1         1     9.62      6.64     3.93     1.21
## 42             1         1         0     9.58      6.99     3.12     0.53
## 43             1         0         1    18.04      5.98     4.33     1.20
## 44             1         1         1     5.25      4.45     2.31     0.65
## 45             0         1         0    13.38      3.54     5.43     2.29
## 46             1         1         0    11.32      4.25     4.63     1.20
## 47             0         0         1     4.84      3.73     1.08     0.16
## 48             1         0         1     9.37      5.53     3.78     0.54
## 49             0         0         1    13.00      5.77     4.70     1.46
## 50             1         1         1     9.44      4.91     5.19     2.56
## 51             0         0         0     6.42      6.42     5.71     0.61
## 52             1         1         0     6.28      5.15     5.15     0.93
## 53             1         1         0    17.79      6.99     8.12     1.73
## 54             1         0         1    11.81      5.79     7.28     1.64
## 55             0         1         0    11.69      4.93     6.09     3.19
## 56             0         0         0     5.56      2.95     2.95     0.17
## 57             1         1         0     7.86      5.11     2.47     0.81
## 58             1         0         0     5.77      5.77     6.98     0.79
## 59             1         0         1    13.04      5.77     3.29     0.84
## 60             1         0         0    12.90      4.20     3.46     1.07
## 61             1         1         1    14.99      2.21     5.52     1.28
## 62             1         1         1     5.30      5.88     5.88     1.16
## 63             0         0         0     6.42      6.41     2.27     0.68
## 64             1         1         0     6.51      7.03     7.03     1.15
##    TBI.dose C1/C2 aKIRs cmv time.to.cmv agvhd time.to.agvhd cgvhd time.to.cgvhd
## 1       200     0     1   1        3.91     1          3.55     0          6.28
## 2       200     1     5   0       65.12     0         65.12     0         65.12
## 3       200     0     3   0        3.75     0          3.75     0          3.75
## 4       200     0     2   0       48.49     1         28.55     1         10.45
## 5       400     0     6   0        4.37     1          2.79     0          4.37
## 6       200     0     2   1        4.53     1          3.88     0          6.87
## 7       400     0     1   0        2.99     0          2.99     0          2.99
## 8       400     0     2   0        4.80     0          4.80     0          4.80
## 9       200     1     2   1        2.73     1          0.69     1          6.21
## 10      400     1     4   0       22.05     0         22.05     1          6.77
## 11      200     1     2   0       14.72     1          2.14     0         14.72
## 12      200     1     4   0        2.40     1          1.41     0          2.40
## 13      200     0     5   1        9.72     0         10.58     1          8.28
## 14      200     1     2   1       11.96     0         12.48     1         11.33
## 15      200     0     2   0        9.59     0          9.59     0          9.59
## 16      200     1     2   1        0.89     0         77.54     1          3.88
## 17      200     1     1   1        3.48     0         21.32     1          3.55
## 18      400     0     2   0       23.95     0         23.95     0         23.95
## 19      400     0     1   0        2.66     1          0.72     0          2.66
## 20      200     1     1   1        4.34     0         85.19     1          3.91
## 21      200     1     5   0       17.71     0         17.71     0         17.71
## 22      200     0     5   0       84.47     0         84.47     1          2.30
## 23      200     0     1   0       15.93     1          3.25     1         10.41
## 24      200     0     5   0       78.29     0         78.29     1          6.44
## 25      200     0     1   0        6.80     0          6.80     0          6.80
## 26      200     0     6   0        0.82     0          0.82     0          0.82
## 27      200     0     4   1        1.12     1          2.63     1          4.34
## 28      200     0     5   1        0.43     0         44.71     0         44.71
## 29      200     1     5   0       16.26     0         16.26     0         16.26
## 30      200     1     1   1        1.12     0         18.53     0         18.53
## 31      200     0     2   1       27.10     1          2.04     1         17.45
## 32      200     1     2   1        3.84     1          0.66     1          6.77
## 33      400     1     1   0       36.67     1          0.76     1         12.91
## 34      200     0     2   0        9.00     1          1.35     0          9.00
## 35      200     1     2   0        6.64     1          2.73     1          3.32
## 36      200     1     1   1        1.12     0         21.68     1         17.22
## 37      200     1     2   1        8.51     0         53.78     1          7.56
## 38      200     0     5   0       50.27     1          1.15     1          3.42
## 39      400     1     4   1        1.02     1          1.15     0          4.57
## 40      200     1     3   1        0.43     0          3.65     0          3.65
## 41      200     1     1   1        3.98     1          2.99     1          3.98
## 42      200     1     4   1        5.26     1          3.29     1         29.17
## 43      200     1     1   1        1.12     1          3.22     0         45.40
## 44      400     0     2   0        3.88     1          2.60     0          3.88
## 45      200     0     1   1        1.35     0          9.66     0          9.66
## 46      400     1     4   1        0.95     1          0.95     0          1.45
## 47      400     0     5   0       29.31     0         29.31     1          6.47
## 48      400     0     5   0       23.66     0         23.66     1          5.26
## 49      400     1     2   0       34.00     0         34.00     1          4.44
## 50      400     1     3   0       32.16     1          2.20     1          3.48
## 51      400     1     1   0        3.61     0          3.61     0          3.61
## 52      400     1     4   0       11.10     0         11.10     1          1.02
## 53      400     0     6   1        3.29     0         31.54     0         31.54
## 54      400     1     1   1        1.12     0         20.34     0         20.34
## 55      400     0     6   0        7.92     0          7.92     0          7.92
## 56      400     1     1   0        8.90     0          8.90     0          8.90
## 57      400     0     1   0        2.07     0          2.07     0          2.07
## 58      400     1     3   1        3.15     1          3.06     0          8.15
## 59      400     0     1   0        3.19     1          0.99     0          3.19
## 60      400     1     2   0       21.68     0         21.68     1          6.70
## 61      400     1     2   1        1.15     0         11.30     0         11.30
## 62      400     1     5   0        7.43     0          7.43     0          7.43
## 63      400     0     5   0       12.88     1          3.32     0         12.88
## 64      400     0     4   0        8.05     0          8.05     1          5.16
##                      diagnosisf
## 1        acute myeloid leukemia
## 2          non-Hodgkin lymphoma
## 3          non-Hodgkin lymphoma
## 4              Hodgkin lymphoma
## 5  acute lymphoblastic leukemia
## 6                 myelofibrosis
## 7        acute myeloid leukemia
## 8        acute myeloid leukemia
## 9             multiple myelomas
## 10 chronic lymphocytic leukemia
## 11            multiple myelomas
## 12       acute myeloid leukemia
## 13     myelodysplastic syndrome
## 14            multiple myelomas
## 15     myelodysplastic syndrome
## 16         non-Hodgkin lymphoma
## 17       acute myeloid leukemia
## 18     myelodysplastic syndrome
## 19         non-Hodgkin lymphoma
## 20 chronic lymphocytic leukemia
## 21     chronic myeloid leukemia
## 22     chronic myeloid leukemia
## 23     myelodysplastic syndrome
## 24                myelofibrosis
## 25       acute myeloid leukemia
## 26         renal cell carcinoma
## 27         renal cell carcinoma
## 28     chronic myeloid leukemia
## 29     myelodysplastic syndrome
## 30 chronic lymphocytic leukemia
## 31            multiple myelomas
## 32         non-Hodgkin lymphoma
## 33             Hodgkin lymphoma
## 34         renal cell carcinoma
## 35         non-Hodgkin lymphoma
## 36     chronic myeloid leukemia
## 37         non-Hodgkin lymphoma
## 38         non-Hodgkin lymphoma
## 39 chronic lymphocytic leukemia
## 40         renal cell carcinoma
## 41            multiple myelomas
## 42     myelodysplastic syndrome
## 43            multiple myelomas
## 44              aplastic anemia
## 45             Hodgkin lymphoma
## 46     myelodysplastic syndrome
## 47            multiple myelomas
## 48 chronic lymphocytic leukemia
## 49                myelofibrosis
## 50         non-Hodgkin lymphoma
## 51       acute myeloid leukemia
## 52            congenital anemia
## 53         non-Hodgkin lymphoma
## 54     myelodysplastic syndrome
## 55       acute myeloid leukemia
## 56       acute myeloid leukemia
## 57       acute myeloid leukemia
## 58                myelofibrosis
## 59         non-Hodgkin lymphoma
## 60         non-Hodgkin lymphoma
## 61       acute myeloid leukemia
## 62     myelodysplastic syndrome
## 63  myeloproliferative disorder
## 64       acute myeloid leukemia

###data.table

library(data.table)
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose
cytomegalovirus= setDT(cytomegalovirus)
cytomegalovirus[, diagnosisf:= as.factor(diagnosis)]

Mean age of patients who have myelofibrosis

myelo_data = cytomegalovirus %>% filter(diagnosis == "myelofibrosis")
mean(myelo_data$age)
## [1] 55.25
mean(cytomegalovirus$age)
## [1] 52.4375