Question

In: Math

How do you plot continuous versus category in r studio

How do you plot continuous versus category in r studio

Solutions

Expert Solution

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.


Related Solutions

how do you test for regression in R studio with variables x and y
how do you test for regression in R studio with variables x and y
Hey anyone good with R studio? How do you create a square shape with R code...
Hey anyone good with R studio? How do you create a square shape with R code by using plot() and lines() please show your code !
In r studio, how do you find significant variables that differ between two datasets of the...
In r studio, how do you find significant variables that differ between two datasets of the same variables?
Plot by hand effective interest rate versus nominal interest rate for continuous compounding.
Plot by hand effective interest rate versus nominal interest rate for continuous compounding.
How do I do this in R Studio? 1 Students who performed poorly on a City...
How do I do this in R Studio? 1 Students who performed poorly on a City of New York Skills Assessment Test were enrolled in a summer math program. Scores of 10 students before and after the summer program were recorded. They were: Before = 18,18,21,18,18,20,23,23,21,17 After = 24,25,33,29,33,36,34,36,34,27 (Scores for individual students are in the same order in each list.) Did the NYC summer math program improve student performance significantly? 8. How many points did student scores improve on...
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2....
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2. How do you graph a zero 3.How do you graph a pole at origin(what does that mean) 4. How do you graph a zero at origin. Please illustrate 1-4 on a graph. indicating which is which please
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2....
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2. How do you graph a zero 3.How do you graph a pole at origin(what does that mean) 4. How do you graph a zero at origin. Please illustrate 1-4 on a graph. indicating which is which please
How do you graph integers in r studio. I made new data frames for specific parts...
How do you graph integers in r studio. I made new data frames for specific parts of the data I wanted to use and then got the sum of a column and saved it as a variable under values. My goal is to know how to graph these integer values in a barplot comparing all the values.
How do I input this in R studio 1. Combine the following lists into a matrix...
How do I input this in R studio 1. Combine the following lists into a matrix called animals, where each list becomes a row: Cats = 2,2,4 Dogs = 1,2,1 Cows = 30,35,41 2. Add column names of “Farm A”, Farm B”, and “Farm C”. 3. Transpose the rows and columns in animals and store the result to a matrix called farms. 4. Display the contents of farms.
How do you create the dot plot?
How do you create the dot plot?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT