# Create sample data
set.seed(123)
n <- 100
df <- data.frame(
x1 = rnorm(n),
x2 = rnorm(n),
x3 = rt(n, df = 3), # Heavy-tailed distribution
x4 = sample(c(0, 1), n, replace = TRUE), # Binary variable
category = sample(letters[1:3], n, replace = TRUE) # Non-numeric column
)
# Add some relationships
df$x2 <- df$x1 + rnorm(n, 0, 0.5)
df$x3 <- df$x1^2 + rnorm(n, 0, 0.5)
# Compute all correlations
result_all <- obcorr(df)
head(result_all)
# Compute only robust correlations
result_robust <- obcorr(df, method = "robust")
# Compute only Pearson correlation with 2 threads
result_pearson <- obcorr(df, method = "pearson", threads = 2)
Run the code above in your browser using DataLab