# Create example dataframe
df <- data.frame(
  col1 = c(10, 20),
  col2 = c(15, 25),
  col3 = c(20, 30)
)

# Method 1: Using base R to calculate mean of all data
overall_mean1 <- mean(unlist(df))
print("Method 1 - Using unlist():")
## [1] "Method 1 - Using unlist():"
print(overall_mean1)
## [1] 20
# Method 2: Using apply function
overall_mean2 <- mean(as.matrix(df))
print("Method 2 - Using as.matrix():")
## [1] "Method 2 - Using as.matrix():"
print(overall_mean2)
## [1] 20