library(readxl) library(ggplot2) library(dplyr) library(sandwich) library(lmtest) library(car) library(MASS) bkf=read_excel("C:/Users/donat.karadayi/Desktop/projeler/BKF Çalışması/yıllara göre tablolar/all_years.xlsx") colnames(bkf)<-c("name","home","province","km","minutes","fairname","participant_count","university_pop","year") #necessary changes bring_rate<-rep(0,times=500) bkf <- cbind(bkf, bring_rate) bkf[bkf == "-"] <- NA bkf$km <- as.numeric(bkf$km) bkf$minutes <- as.numeric(bkf$minutes) bkf$participant_count <- as.numeric(bkf$participant_count) bkf$university_pop <- as.numeric(bkf$university_pop) bkf$year <- as.numeric(bkf$year) #subsets bkf19<-subset(bkf,bkf$year=="2019") bkf20<-subset(bkf,bkf$year=="2020") bkf22<-subset(bkf,bkf$year=="2022") bkf24<-subset(bkf,bkf$year=="2024") # Extract unique university names university_names <- unique(bkf$name) # Convert to a data frame university_names_df <- data.frame(university_name = sort(university_names)) university_names_df bkf<-na.omit(bkf) #Bring rate hesabı hepsi için for(i in 1:356){ bkf$bring_rate[i]=((bkf$participant_count[i]*100)/bkf$university_pop[i]) print(bkf$bring_rate[i]) } bkfhome<-subset(bkf,bkf$home==1) bkfaway<-subset(bkf,bkf$home==0) ########################################################################################################################## # Count the occurrences of each university university_counts <- table(bkfaway$name) # Get universities that appear only once universities_once <- names(university_counts[university_counts == 1]) # Print the list of universities that appear only once universities_once # Step 3: Subset the data set for universities that appear only once bkfaway_one_time <- bkfaway[bkfaway$name %in% universities_once, ] # View the resulting subset head(bkfaway_one_time) # Check how many universities appear only once length(universities_once) # Check how many rows are in the resulting subset nrow(bkfaway_one_time)