read through a loop of csv files and return which ones have 30 variables in r
main.r
# List all CSV files in the working directoryfile_list <- list.files(pattern = "\\.csv$")
# Create a vector to store names of files with 30 variablesfiles_with_30_vars <- c()
# Loop through each file and check if it has 30 variablesfor(file in file_list) {
data <- read.csv(file)
if(ncol(data) == 30) {
files_with_30_vars <- c(files_with_30_vars, file)
}
}
# Display file names with 30 variablesprint(files_with_30_vars)