# Test R Script for VSCode Setup # This script demonstrates basic R functionality # Basic operations x <- 1:10 y <- x^2 cat("=== Basic R Test ===\n") cat("Vector x:", x, "\n") cat("Vector y:", y, "\n") cat("Mean of x:", mean(x), "\n") cat("Sum of y:", sum(y), "\n") cat("Standard deviation of x:", sd(x), "\n\n") # Data frame example df <- data.frame( id = 1:5, name = c("Alice", "Bob", "Charlie", "Diana", "Eve"), age = c(25, 30, 35, 28, 32), score = c(85, 92, 78, 96, 88) ) cat("=== Data Frame Example ===\n") print(df) cat("\n") # Statistical summary cat("=== Statistical Summary ===\n") cat("Summary of scores:\n") print(summary(df$score)) cat("\n") # Simple function calculate_stats <- function(data) { list( mean = mean(data), median = median(data), min = min(data), max = max(data) ) } cat("=== Custom Function Test ===\n") stats <- calculate_stats(df$score) print(stats) cat("\n") # Plot example (will create a plot if run in R) cat("=== Plot Information ===\n") cat("To create a plot, run this script in R and use:\n") cat("plot(x, y, main = 'Test Plot: y = x^2', type = 'b', col = 'blue')\n") cat("hist(df$score, main = 'Score Distribution', col = 'lightgreen')\n\n") cat("✅ R script executed successfully!\n") cat("Your R environment is working correctly.\n")