---
# System prepended metadata

title: PID-601

---

To perform a Chi Square test of independence on the data set "collegePlacement.csv" using R programming, we can follow these steps:

1. Import the data set into R using the `read.csv()` function.
2. Create a contingency table of the variables of interest using the `table()` function.
3. Use the `chisq.test()` function to perform the Chi Square test of independence for each pair of selected categorical variables against the "PlacedOrNot" variable:.

Here's an example

```R
# Load the required library for Chi-Square test
library(stats)

# Read the CSV file into a dataframe
collegePlacement <- read.csv("collegePlacement.csv")

# List of categorical variables to test
variables_to_test <- c("Age", "Gender", "Stream", "Internship", "CGPA", "Hostel", "HistoryOfBacklogs")

# Create an empty list to store results
results_list <- list()

# Loop through variable pairs and perform Chi-Square tests
for(var in variables_to_test){
  contingency_table <- table(collegePlacement[[var]], collegePlacement$PlacedOrNot)
  chi_square_test <- chisq.test(contingency_table)
  results_list[[var]] <- chi_square_test
}

# Print results
for(var in variables_to_test){
  print(paste("Chi-Square Test for", var))
  print(results_list[[var]])
  cat("\n")
}
```
Make sure to place the "collegePlacement.csv" file in the working directory or provide the full path to the file in the `read.csv()` function. This code will read the data, perform Chi-Square tests of independence for each variable against "PlacedOrNot," and print the results for each variable pair.