i need to create a list of vectors from my dataframe 'patientdata' in the next way: for the first element of list: a vector of age of patients of Type1, for the second element of list: a vector of age of patients of Type2
Note that this is only a part of my big dataframe, in the real dataframe there is much more Type (Type3, Type4, ...). So the list need to be greater than 2 as i asked above, it depends of the number of Type.
here my dataframe:
patientID <- c(1, 2, 3, 4)
age <- c(25, 34, 28, 52)
diabetes <- c("Type1", "Type2", "Type1", "Type1")
status <- c("Poor", "Improved", "Excellent", "Poor")
patientdata <- data.frame(patientID, age, diabetes, status)
can someone help me please ?