I asked this question over on Stackoverflow a few days ago, but haven't received an answer. I went through all 12 pages on SO regarding grouped barplots but just couldn't find a way to do what I wanted. I went through most of the online resources as well, including R cookbook and still haven't found a solution to this. I do believe however, its based on me not understanding something fundamental in R, so sorry in advance.

I have data, where I have blood values of cancer patients and their survival data. I've run some survival curves, log-rank tests, and cox-regression analysis and see that higher values correlate with worse prognosis. So what I'd like to do is now plot all cancer patients' blood values and group them by those with better and those with worse prognosis, where better/worse is defined as survival above/below the median survival of the cohort.

This is how my data is organized:

PatientID Survival Death BloodValue

1 1856 0 1040.58

2 492 1 2087.00

... ... ... ...

median(Survival) = 1277.

So,

barplot(BloodValue[Survival>=1277])

gives me the barplot for just those patients with Survival over the median.

Doing

barplot(BloodValue[Survival>=1277], BloodValue[Survival

More Oliver Maximilian Fisher's questions See All
Similar questions and discussions