In: Statistics and Probability
year | elevation | nest_id | density_stems | wall_thickness |
2010 | high | 10-056 | 3.18471338 | 3.1 |
2010 | high | 10-011 | 4.45859873 | 5.5 |
2010 | high | 10-124 | 7.00636943 | 3.5 |
2010 | high | 10-199 | 7.96178344 | 3.6 |
2010 | high | 10-217 | 7.96178344 | 4.3 |
2010 | high | 10-066 | 8.59872612 | 3.1 |
2010 | high | 10-087 | 9.87261147 | 4 |
2010 | high | 10-099 | 10.1910828 | 1.8 |
2010 | high | 10-110 | 11.4649682 | 3 |
2010 | high | 10-105 | 13.3757962 | 5.8 |
2010 | high | 10-082 | 16.2420382 | 2.8 |
2010 | high | 10-118 | 17.5159236 | 3.2 |
2010 | high | 10-152 | 17.5159236 | 4.1 |
2010 | high | 10-213 | 17.5159236 | 4.8 |
2010 | high | 10-147 | 18.1528662 | 4 |
2010 | high | 10-106 | 18.4713376 | 3 |
2010 | high | 10-053 | 18.4713376 | 3.7 |
2010 | high | 10-107 | 19.7452229 | 4.5 |
2010 | high | 10-018 | 20.3821656 | 2.9 |
2010 | high | 10-208 | 20.7006369 | 4.3 |
2010 | high | 10-159 | 21.3375796 | 3.8 |
2010 | high | 10-083 | 21.656051 | 3.2 |
2010 | high | 10-037 | 21.656051 | 3.4 |
2010 | high | 10-117 | 21.9745223 | 3.7 |
2010 | high | 10-051 | 22.611465 | 3.5 |
2010 | high | 10-164 | 23.566879 | 2.8 |
2010 | high | 10-211 | 25.1592357 | 2.9 |
2010 | high | 10-214 | 27.0700637 | 4.2 |
2010 | high | 10-039 | 28.9808917 | 5.1 |
2010 | high | 10-081 | 31.2101911 | 2.1 |
2010 | high | 10-190 | 31.2101911 | 3.7 |
2010 | high | 10-148 | 31.5286624 | 3.5 |
2010 | high | 10-184 | 34.3949045 | 3.3 |
2010 | high | 10-158 | 38.5350319 | 3.5 |
2010 | high | 10-100 | 43.9490446 | 4.4 |
2010 | high | 10-166 | 59.5541401 | 3.5 |
2010 | low | 10-060 | 1.27388535 | 1.6 |
2010 | low | 10-103 | 1.27388535 | 1.7 |
2010 | low | 10-068 | 2.22929936 | 3.3 |
2010 | low | 10-142 | 3.18471338 | 0.8 |
2010 | low | 10-067 | 4.45859873 | 1.7 |
2010 | low | 10-179 | 4.77707006 | 1.6 |
2010 | low | 10-160 | 6.05095541 | 1.5 |
2010 | low | 10-113 | 8.59872612 | 2.2 |
2010 | low | 10-151 | 8.91719745 | 1.2 |
2010 | low | 10-091 | 8.91719745 | 1.7 |
2010 | low | 10-072 | 10.1910828 | 3.5 |
2010 | low | 10-041 | 10.8280255 | 1.8 |
2010 | low | 10-173 | 11.1464968 | 2.4 |
2010 | low | 10-189 | 11.4649682 | 1.3 |
2010 | low | 10-145 | 11.7834395 | 2.6 |
2010 | low | 10-059 | 13.6942675 | 3.4 |
2010 | low | 10-119 | 15.2866242 | 1.8 |
2010 | low | 10-086 | 16.2420382 | 1.8 |
2010 | low | 10-025 | 16.2420382 | 3.9 |
2010 | low | 10-130 | 17.1974522 | 3 |
2010 | low | 10-002 | 19.4267516 | 2.7 |
2010 | low | 10-129 | 23.8853503 | 1.1 |
2010 | low | 10-188 | 25.477707 | 2.5 |
Hw to display the difference in mean nest wall thickness between altitudes with a violin plot using the R studio with ggplot2? ( Dependent: wall thickness; Independent: elevation) And could you please show me both graph and code? Thanks!!
Sol:
Use R studio
R code was
library(readxl)
nest_wall_thickness <-
read_excel("C:/Users/Downloads/nest_wall_thickness.xlsx")
View(nest_wall_thickness)
head(nest_wall_thickness)
library(ggplot2)
# Basic violin plot
p <- ggplot(nest_wall_thickness, aes(x=elevation,
y=wall_thickness)) +
geom_violin()
p
# violin plot with mean points
p + stat_summary(fun.y=mean, geom="point", shape=23,
size=5,color="brown")
output:
Rscreenshot