In: Math
Continuous data are those which can take any value between a set of finite or infinite intervals. Categorical data on the other hand can take on one of a limited, and usually fixed number of possible value.
Let us consider a continuous vs categorical data as below,
Here, we have a categorical variable Sex (divided into 2 categories) and we have a continuous variable Age.
To plot the two variables, we can use two boxplots.
For plotting the two box-plots in R we can use the following code:
Sex=data$Sex
Age=data$Age
boxplot(Age~Sex,
main= "Different boxplot for each sex showing distribution of age
",
col="green", border="black",
xlab="Sex",
ylab="Age")
We get the boxplot as follows:
We can also plot a age vs sex graph as follows:
The R code:
plot(cut(Age,6)~Sex,col=colors()[070:072],
ylab="Age groups",
main="Age groups vs Sex")
Here, the age group is divided into 6 groups and we get two bars for male and female for the 6 groups.