Library being used

library(vtable)
Warning: package 'vtable' was built under R version 4.1.2
Loading required package: kableExtra
Warning: package 'kableExtra' was built under R version 4.1.2
library(ggplot2)
library(dplyr)
Warning: package 'dplyr' was built under R version 4.1.2

Attaching package: 'dplyr'
The following object is masked from 'package:kableExtra':

    group_rows
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Importing data in R-Studio

#Convert the dataset in to a .csv format

mosquito_df <- read.csv("~/Desktop/MRes/Research Methods/Formative/mosquitos.csv"
                        , header = TRUE)

Finding the summary

summary (mosquito_df)
       ID              wing           sex           
 Min.   :  1.00   Min.   :25.16   Length:100        
 1st Qu.: 25.75   1st Qu.:41.42   Class :character  
 Median : 50.50   Median :48.42   Mode  :character  
 Mean   : 50.50   Mean   :48.78                     
 3rd Qu.: 75.25   3rd Qu.:56.24                     
 Max.   :100.00   Max.   :69.82                     
vtable (mosquito_df)
mosquito_df
Name Class Values
ID integer Num: 1 to 100
wing numeric Num: 25.158 to 69.818
sex character

Finding the data type

sapply (mosquito_df, class)
         ID        wing         sex 
  "integer"   "numeric" "character" 

Finding the structure of the data

str (mosquito_df)
'data.frame':   100 obs. of  3 variables:
 $ ID  : int  1 2 3 4 5 6 7 8 9 10 ...
 $ wing: num  37.8 50.6 39.3 38.1 25.2 ...
 $ sex : chr  "f" "f" "f" "f" ...

Visualizing Correlations

mosquito_df %>%
  ggplot(aes(x = sex, y = wing)) +  
  geom_point() +
  labs(x = "Sex", 
       y = "Count", 
       fill = "Sex", 
       color = "Sex", 
       title = "Mosquitos counting by Sex") + 
  theme_minimal() +
  theme(axis.text = element_text(size = 14),
        axis.title = element_text(size = 14))

Visualizing Histograms

mosquito_df %>%
  ggplot(aes(x = wing, color = sex, fill = sex)) +
  geom_histogram(alpha = 0.5, bins = 30) +
  labs(x = "Wing Length", 
       y = "Count", 
       fill = "Sex", 
       color = "Sex", 
       title = "Wing Length Distribution by Sex") +
  theme_minimal() +  
  theme(axis.text = element_text(size = 14),
        axis.title = element_text(size = 14))

Visualizing Barchart

mosquito_df %>%
  ggplot(aes(x = sex, color = sex, fill = sex)) +
  geom_bar(alpha = 0.5) +
  labs(x = "Sex", 
       y = "Count", 
       fill = "Sex", 
       color = "Sex", 
       title = "Mosquitos counting by Sex") +
  theme_minimal() +
  theme(axis.text = element_text(size = 14),
        axis.title = element_text(size = 14))