ls()
[1] "anova_bat_brands" "anova_result" "Batteries" "Batteries_df"
[5] "Batteries_temp_mat" "Boston_df" "chick_aov" "chickwts"
[9] "cor_value" "doubles_hit" "firstbasestats" "growth_df"
[13] "Hitters_Fixed" "Hitters_Fixed_df" "mean_mat_temp_combinations" "model"
[17] "one_way_plant_growth" "p_values" "PlantGrowth" "predicted_speed"
[21] "reg_medv_lstat" "sorted_p" "tukey_result" "twoway_breaks_yar"
[25] "twoway_growth" "twoway_temp_mat" "warpbreaks"
doubles_hit # prints the whole thing (only good for small datasets)
NA
#EXtract
doubles <- doubles_hit$doubles
## [1] 13.37371
class(doubles) # should say "numeric" or "integer"
[1] "integer"
length(doubles) # should be 100, matching your dataset
[1] 100
#Step 2: Mean, median, standard deviation
# Mean
doubles_mean <- mean(doubles)
doubles_mean
# Median
doubles_median <- median(doubles)
doubles_median
# Number of observations
doubles_n <- length(doubles)
doubles_n
# Standard deviation
doubles_sd <- sd(doubles)
doubles_sd
#Step 3: Percentage within one standard deviation
doubles_w1sd <- sum((doubles - doubles_mean)/doubles_sd < 1)/doubles_n
doubles_w1sd
[1] 0.79
## Difference from empirical rule
doubles_w1sd - 0.68
[1] 0.11
#Step 4: Percentage within two standard deviations
doubles_w2sd <- sum((doubles - doubles_mean)/doubles_sd < 2)/doubles_n
doubles_w2sd
[1] 1
## Difference from empirical rule
doubles_w2sd - 0.95
[1] 0.05
#Step 5: Percentage within three standard deviations
doubles_w3sd <- sum((doubles - doubles_mean)/doubles_sd < 3)/doubles_n
doubles_w3sd
[1] 1
## Difference from empirical rule
doubles_w3sd - 0.9973
[1] 0.0027
#Step 6: Histogram
hist(doubles, xlab = "Number of Doubles Hit", col = "green", border = "red",
xlim = c(0,50), ylim = c(0,30), breaks = 5)
Notes on interpretation:
The distribution is roughly spread from 1 to 49 doubles, with a mean of 23.55 and median of 23.5, so it’s fairly symmetric (mean ≈ median). All 100 observations fall within two standard deviations of the mean (and three), which is why those percentages hit 100%. The one-standard-deviation figure (79%) is a bit higher than the 68% predicted by the empirical rule, which can happen with smaller or slightly non-normal datasets. The histogram shows the data isn’t perfectly bell-shaped — there’s a noticeable cluster of high values (40s) alongside the main body, suggesting a bit of right-side clustering rather than a single smooth peak.