library(ggplot2)
data <- read.csv(“t.csv”)
data_subset <- data[1:200, ]
data_subset\(RR <- as.numeric(as.character(data_subset\)RR)) data_subset\(VO2 <- as.numeric(as.character(data_subset\)VO2)) data_subset\(time <- as.numeric(as.character(data_subset\)time)) data_subset\(power <- as.numeric(as.character(data_subset\)power))
mean_amp <- mean(data_subset\(RR, na.rm = TRUE) sd_amp <- sd(data_subset\)RR, na.rm = TRUE)
cat(“Mean of RR (R-peak amplitude surrogate):”, mean_amp, “”) cat(“Standard Deviation of RR:”, sd_amp, “”)
hist(data_subset\(RR, main = "Distribution of RR Intervals", xlab = "RR Interval (s)", ylab = "Frequency", col = "lightblue", border = "white") lines(density(data_subset\)RR, na.rm = TRUE), col = “red”, lwd = 2)
t_vo2 <- t.test(data_subset$VO2, mu = 40, alternative = “two.sided”) cat(“Hypothesis Test for VO2:”) print(t_vo2)
cor_test <- cor.test(data_subset\(time, data_subset\)power, method = “pearson”) cat(“Test between Time and Power:”) print(cor_test)
ggplot(data_subset, aes(x = RR, y = time)) + geom_point(color = “darkgreen”, alpha = 0.6) + geom_smooth(method = “lm”, color = “red”, se = TRUE) + labs(title = “Correlation between Time and RR Interval”, x = “RR Interval (s)”, y = “Time (s)”) + theme_minimal()
r_value <- cor(data_subset\(RR, data_subset\)time, use = “complete.obs”) cat(“coefficient between RR and Time:”, r_value, “”)
cat(“—– SUMMARY —–”) cat(“Mean RR:”, mean_amp, “”) cat(“SD RR:”, sd_amp, “”) cat(“Correlation (Time vs Power):”, cor_test$estimate, “”) cat(“Correlation (Time vs RR):”, r_value, “”) cat(“——————–”) setwd(“C:/Users/91824/Desktop)