Learn R Programming

UAHDataScienceSF (version 1.0.0)

harmonic_mean: Harmonic Mean Function

Description

This function calculates the harmonic mean of a numbers vector.

Usage

harmonic_mean(x = NULL, learn = FALSE, interactive = FALSE)

Value

The harmonic mean of the vector (for non-interactive mode)

Arguments

x

Optional numeric vector (not needed for interactive mode)

learn

Logical, if TRUE shows step-by-step explanation

interactive

Logical, if TRUE enables interactive practice mode

Examples

Run this code
data <- c(1,4,3,3,2,5,7,12,1,2,3,12)

# Simple calculation
harmonic_mean(data)

# Learning mode
harmonic_mean(data, learn = TRUE)

# Interactive mode
if(interactive()){
harmonic_mean(interactive = TRUE)
}

Run the code above in your browser using DataLab