Reputation: 193
I have this dataset of breast cancer
install.packages("vcdExtra")
library(vcdExtra)
?Cancer
df_cancer<-as.data.frame(Cancer)
This data set is
Survival Grade Center Freq
1 Died Malignant Boston 35
2 Surv Malignant Boston 59
3 Died Benign Boston 47
4 Surv Benign Boston 112
5 Died Malignant Glamorgan 42
6 Surv Malignant Glamorgan 77
7 Died Benign Glamorgan 26
8 Surv Benign Glamorgan 76
I want to do graphs to view the supervivence ratio by grade and by center, but I don't know how to deal with the column of frequency because when I do a barplot or anything like that it counts the frequency in the dataset.
Upvotes: 0
Views: 103
Reputation: 19726
If you want the heights of the bars to represent values in the data, you can use geom_col
with ggplot2
Here is an example with Cancer
data
library(ggplot2)
ggplot(df_cancer)+
geom_col(aes(x = Survival, y = Freq, fill = Grade), position = "dodge")+
facet_wrap(~Center)
I'd rather be in Boston
Upvotes: 1