-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_r_environment.R
More file actions
81 lines (69 loc) · 2.92 KB
/
setup_r_environment.R
File metadata and controls
81 lines (69 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# ============================================================================
# R Package Installation Script
# Online Shopper's Intention (OSI) Analysis Project
# ============================================================================
# This script installs all required R packages for the OSI analysis project
# Run this script once before executing the main analysis
# ============================================================================
# Function to check and install packages
install_if_missing <- function(packages) {
for (pkg in packages) {
if (!require(pkg, character.only = TRUE, quietly = TRUE)) {
message(paste("Installing package:", pkg))
install.packages(pkg, dependencies = TRUE)
} else {
message(paste("Package already installed:", pkg))
}
}
}
# List of required packages
required_packages <- c(
# Data Manipulation & Visualization
"tidyverse", # Collection of data science packages (includes dplyr, ggplot2, stringr)
"ggplot2", # Data visualization
"dplyr", # Data manipulation
"stringr", # String operations
# Statistical Analysis
"moments", # Skewness and kurtosis analysis
"zoo", # Time series and rolling calculations
# Machine Learning & Classification
"caret", # Classification and Regression Training
"e1071", # Support Vector Machines (SVM)
"rpart", # Decision Trees (CART)
"rpart.plot", # Decision tree visualization
"randomForest", # Random Forest classifier
# Clustering & Dimensionality Reduction
"factoextra", # PCA and clustering visualization
# Model Evaluation
"pROC" # ROC curve analysis and AUC calculation
)
# Install packages
message("==============================================================")
message("Starting package installation for OSI Analysis Project")
message("==============================================================\n")
install_if_missing(required_packages)
message("\n==============================================================")
message("Package installation complete!")
message("==============================================================")
# Verify installation
message("\nVerifying package installation...\n")
all_installed <- TRUE
for (pkg in required_packages) {
if (require(pkg, character.only = TRUE, quietly = TRUE)) {
message(paste("✓", pkg, "- OK"))
} else {
message(paste("✗", pkg, "- FAILED"))
all_installed <- FALSE
}
}
if (all_installed) {
message("\n✓ All packages installed successfully!")
message("You can now run the analysis script: DSC 441 HW5.Rmd")
} else {
message("\n✗ Some packages failed to install. Please check the error messages above.")
}
# Print R session info
message("\n==============================================================")
message("R Session Information:")
message("==============================================================")
print(sessionInfo())