Question
Hello, This question is for an R data analysis assignment. The question and the code are provided. I get getting an error in my R
Hello,
This question is for an R data analysis assignment. The question and the code are provided.
I get getting an error in my R code stating: "Error in eval(e, x, p)rent.frame()): object 'TYPE' not found.
Here is the question:
5(c) (3 points) Present four boxplots using *par(mfrow = c(2, 2)* or *grid.arrange()*. The first line should show VOLUME by RINGS for the infants and, separately, for the adult; factor levels "M" and "F," combined. The second line should show WHOLE by RINGS for the infants and, separately, for the adults. Since the data are sparse beyond 15 rings, limit the displays to less than 16 rings. One way to accomplish this is to generate a new data set using subset() to select RINGS < 16.Use ylim = c(0, 1100) for VOLUME and ylim = c(0, 400) for WHOLE.If you wish to reorder the displays for presentation purposes or use ggplot2 go ahead
Here is my code:
md_ss <- subset(mydata, RINGS < 16)
vi <- ggplot(subset(md_ss, TYPE == 'I'), aes(x=RINGS, y=VOLUME, fill=RINGS, group=RINGS)) +
geom_boxplot() +
ggtitle('Infant Volume | Rings') +
theme(plot.title = element_text(hjust = 0.5))
va <- ggplot(subset(md_ss, TYPE == '"F","M"'), aes(x=RINGS, y=VOLUME, fill=RINGS, group=RINGS)) +
geom_boxplot() +
ggtitle('Adult Volume | Rings') +
theme(plot.title = element_text(hjust = 0.5))
wi <- ggplot(subset(md_ss, TYPE == 'I'), aes(x=RINGS, y=WHOLE, fill=RINGS, group=RINGS)) +
geom_boxplot() +
ggtitle('Infant Whole | Rings') +
theme(plot.title = element_text(hjust = 0.5))
wa <- ggplot(subset(md_ss, TYPE == 'ADULT'), aes(x=RINGS, y=WHOLE, fill=RINGS, group=RINGS)) +
geom_boxplot() +
ggtitle('Adult Whole | Rings') +
theme(plot.title = element_text(hjust = 0.5))
grid.arrange(vi, va, wi, wa, ncol=2)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started