R Markdown

##library(tidyverse)

winglength <- function(x) {
   n = length(x) ##assigns n as sample size
   mean_wl = mean(x) ##mean of selected dataset
   standard_deviation = sd(x) ## sd of selected dataset
   standard_error_of_mean = sd(x)/sqrt(n) ##SEoM of selected dataset
   Coefficient_variation = standard_deviation/mean_wl ##coefficient of variation of selected dataset
   output = c(standard_error_of_mean,Coefficient_variation) ## 
   names(output) = c("Standard error of the mean","Coefficient of Variation") 
   return(output) 
   }

winglength.males <- c(62,64,71,59,66)
winglength.females <- c(58, 62, 54, 61, 51)
winglength.all <- c(62,64,71,59,66,58,62,54,61,51)

male_summary <- winglength(winglength.males)
print(male_summary <- winglength(winglength.males))
## Standard error of the mean   Coefficient of Variation 
##                 2.01494417                 0.06996199
female_summary <- winglength(winglength.females)
print(female_summary <- winglength(winglength.females))
## Standard error of the mean   Coefficient of Variation 
##                 2.08326667                 0.08143926
all_summary <- winglength(winglength.all)
print(all_summary <- winglength(winglength.all))
## Standard error of the mean   Coefficient of Variation 
##                 1.81842423                 0.09457833
repairs <- c(0,1,2,3,5,8)
frequency <- c(64,16,8,2,1,1)

repairs.1 <- rep(repairs, frequency)

machine.repairs = function(repairs.1) {
  mean_repairs = mean(repairs.1)
  standard.deviation = sd(repairs.1)
  variance = sd(repairs.1)^2
  outputs = c(mean, standard.deviation, variance) ## creates vector containing all outputs
  names(outputs) = c("mean", "standard deviation", "variance") ## gives each output value a name
  return(outputs) ## forces error "output" to be the return value
} 

machine.repairs(repairs.1)
## $mean
## function (x, ...) 
## UseMethod("mean")
## <bytecode: 0x130f0de70>
## <environment: namespace:base>
## 
## $`standard deviation`
## [1] 1.180092
## 
## $variance
## [1] 1.392618