我不是学这个的,老师上课突发奇想教我们这个,没基础,不会做。(这个凑字数)
my_scatterplot <- function(x, y) {
# Create the scatterplot
plot(x, y, xlab = "x", ylab = "y")
# Calculate the correlation coefficient
cor_coef <- cor(x, y)
cat("The correlation coefficient is:", cor_coef)
# Return the correlation coefficient
return(cor_coef)
}
sum_and_sumsq <- function(x) {
sum_x <- sum(x)
sum_xsq <- sum(x^2)
return(list(sum_x = sum_x, sum_xsq = sum_xsq))
}