'representation of two bars for each range in R
I have been trying to make a bar-chart but I am pretty stuck at the data modeling and presentation of it. Code is below. the fixedTable is a data frame which I take data from him,and the logic vector is the columns that I need from my data set(here there is no problem).
in this link there is an example of the wanted plot. but instead of china and Italy there should be 0 and 1. for example: in the age group of 50-59 there are 49 survived(1) and 40 not survived(0).hence,the range of this group needs to include the two bars:1 with height of 49 and 0 with height of 40.
code:
ageAndSurvived<-subset(fixedTable,select = logicVector)
x<-split(ageAndSurvived,cut(ageAndSurvived$Age,seq(0,100,by=10))) #tried this but didnt help much
head(ageAndSurvived)
## Survived Age
## 1 0 22
## 2 1 38
## 3 1 26
## 4 1 35
## 5 0 35
## 7 0 54
for example:in the third row there is a person who survived and his age is 26.
I would be glad for a way how to do it. prefer with base R. thank you very much in advance! :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
