penguins %>%ggplot(aes(x=bill_length_mm, y = bill_depth_mm))+geom_point()+geom_smooth(method ="lm")+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
penguins %>%ggplot(aes(x=bill_length_mm, y = bill_depth_mm,color=species, fill=species))+geom_point()+geom_smooth(method ="lm",se=FALSE)+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
penguins %>%na.omit() %>%ggplot(aes(x=sex, y = body_mass_g,color=species, fill=species))+geom_boxplot(alpha=0.7)+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))
penguins %>%na.omit() %>%ggplot(aes(x=species, y = body_mass_g,color=sex, fill=sex))+geom_boxplot(alpha=0.7)+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))
Question 1
Can Body mass predict bill length?
How to find answer?
Need to find relationship between the body mass and bill length
Scatter-plot with a linear regression will help to do this
library(ggplot2)penguins%>%na.omit() %>%ggplot(aes(x=body_mass_g, y = bill_length_mm,color=species,))+geom_point()+geom_smooth(method ="lm", se=FALSE)+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))+labs(title ="Body mass vs bill length by Specues")
`geom_smooth()` using formula = 'y ~ x'
Discussion
The trend between body mass and bill length within each species is shown by the linear regression lines for that species.
Positive Correlation: Body mass and bill length are positively correlated for all three species. Bill length tends to rise in tandem with body bulk.
Variations by Species:
When compared to the other two species, the gentoo (blue) typically has the largest body mass and longest bill.
Chinstrap (green): This species’ body mass and bill length fall into an intermediate range.
Adelie (red): The body bulk and length of the bill are typically the lowest in this species.
Conclusion
Body mass can be used to predict bill length, according to the scatterplot with regression lines; the strength of this association varies slightly between species. There may be some variance around the trend lines, though, so this relationship may not be entirely linear.
Question 2
Does sex explain flipper length
To this need to find significant difference between flipper length between male and female penguins.
library(ggplot2)penguins%>%na.omit() %>%ggplot(aes(x=sex, y =flipper_length_mm,fill=species))+geom_boxplot()+theme(axis.text=element_text(size=16),axis.title=element_text(size=16))+labs(title ="Flipper length by sex and species")
Discussion
Gentoo penguins (blue) have the longest flipper lengths overall, regardless of sex.
Chinstrap penguins (green) have intermediate flipper lengths.
Adelie penguins (red) have the shortest flipper lengths.
For each species, males tend to have longer flippers compared to females, as shown by the higher median values for males.
Conclusion
Gentoo males have the longest flippers, with a median flipper length around 220 mm, while Adelie females have the shortest median flipper length, just below 190 mm.
According to the figure, flipper length is highly influenced by both sex and species. Gentoo penguins often have the longest flippers of any sex, with males typically having longer flippers than females.
Hello Week 4 Assessment
library(tidyverse)library(modeldata)
Attaching package: 'modeldata'
The following object is masked _by_ '.GlobalEnv':
penguins
The following object is masked from 'package:palmerpenguins':
penguins
#Modifying basic properties of the plotggplot(crickets, aes(x=temp, y=rate, color=species))+geom_point(color="red", size=2,alpha=.3, shape="square")+labs(x="Temperature", y="Chirp rate", color="Species",title ="Cricket chirps",caption ="Source: McDonald (2009)" )
# Learn more about the options for the geom# with ?geom_point#adding another layerggplot(crickets, aes(x=temp, y=rate,))+geom_point()+geom_smooth(method ="lm", se=FALSE)+labs(x="Temperature", y="Chirp rate",title ="Cricket chirps",caption ="Source: McDonald (2009)" )