library(tidyverse)
library(ggplot2)
library(readxl)
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Challenge 9 - Wild Bird
challenge_9
wild_bird
srujan_kagitala
Creating a function
Challenge Overview
Today’s challenge is simple. Create a function, and use it to perform a data analysis / cleaning / visualization task:
Examples of such functions are: 1) A function that reads in and cleans a dataset.
2) A function that computes summary statistics (e.g., computes the z score for a variable).
3) A function that plots a histogram.
That’s it!
Read
Using “wild_bird_data.xlsx” dataset.
<- read_excel("_data/wild_bird_data.xlsx", skip = 1)
wild_bird_data wild_bird_data
Function
Creating a function to show statistics like mean, median, min, max, IQR, standard deviation and variance
#Function to give statistics
<- function(data, col_name){
statistics %>%
data select({{col_name}}) %>%
summarise_all(list(mean = mean,
median = median,
min = min,
max = max,
IQR = IQR,
sd = sd,
var = var), na.rm = TRUE)
}
Statistics of wet body weight of wild birds.
statistics(wild_bird_data,`Wet body weight [g]`)