Rewrite this R code to Julia:
library(parallel)
library(foreach)
library(doParallel)
#"C:\Users\Michał\Desktop\player22.csv"
Data<-read.csv("C:/Users/Użytkownik/Desktop/player22.csv")

RW_idx <- which(grepl("RW", Data$Positions))
ST_idx <- which(grepl("ST", Data$Positions))
GK_idx <- which(grepl("GK", Data$Positions))
CM_idx <- which(grepl("CM", Data$Positions))
LW_idx <- which(grepl("LW", Data$Positions))
CDM_idx <- which(grepl("CDM", Data$Positions))
LM_idx <- which(grepl("LM", Data$Positions))
CF_idx <- which(grepl("CF", Data$Positions))
CB_idx <- which(grepl("CB", Data$Positions))
CAM_idx <- which(grepl("CAM", Data$Positions))
LB_idx <- which(grepl("LB", Data$Positions))
RB_idx <- which(grepl("RB", Data$Positions))
RM_idx <- which(grepl("RM", Data$Positions))
LWB_idx <- which(grepl("LWB", Data$Positions))
RWB_idx <- which(grepl("RWB", Data$Positions))

c<-2
#############
a<-6/0


position_vectors <- list(RW_idx, ST_idx, GK_idx, CM_idx, LW_idx, 
                         CDM_idx, LM_idx, CF_idx, CB_idx, CAM_idx,
                         LB_idx, RB_idx, RM_idx, LWB_idx, RWB_idx)



position_vectors_list<-position_vectors

##############


# Mutation 2

mutate <- function(selected_players_df, position_vectors_list, probability) {
  n_rows <- nrow(selected_players_df)
  selected_players_matrix <- selected_players_df
  
  select_random_player <- function(idx_list, selected_players = NULL) {
    repeat {
      random_idx <- sample(idx_list, 1)
      if (!random_idx %in% selected_players) {
        return(random_idx)
      }
    }
  }
  
  for (i in 1:n_rows) {
    for (pos_idx in 1:length(position_vectors_list)) {
      if (runif(1) <= probability) {
        selected_players_matrix[i, pos_idx] <- select_random_player(position_vectors_list[[pos_idx]], 
                                                                    selected_players = selected_players_matrix[i, ])
      }
    }
  }
  
  selected_players_df <- data.frame(selected_players_matrix)
  return(selected_players_df)
}

n_rows<-100

pop_init<- as.data.frame(matrix(NA, n_rows, length(position_vectors)))
pop_init<- mutate(pop_init, position_vectors_list, probability=1)




#######Target

row1<-pop_init[1,]


target <- function(row1,penalty=5) {
  position_ratings <- c("RWRating", "STRating", "GKRating", "CMRating",
                        "LWRating", "CDMRating", "LMRating", "CFRating",
                        "CBRating", "CAMRating", "LBRating", "RBRating",
                        "RMRating", "LWBRating", "RWBRating")
  
  row1<-as.matrix(row1,nrow=1)
  parent_data <- Data[row1, ]
  ratings <- parent_data[position_ratings]
  ratings_log <- log(ratings)
  
  potential_minus_age <- 0.15*parent_data$Potential - 0.6*parent_data$Age
  int_reputation <- parent_data$IntReputation
  
  sumratings<-0
  rating_list<-c()
  for (i in 1:15){
    temp<-ratings_log[i,i]
    sumratings<-sumratings+temp
    rating_list<-append(rating_list, temp)
    
    
  }
  
  
  
  
  # Apply constraints
  constraint_penalty <- 0
  if (sum(parent_data$ValueEUR) > 250000000) {
    constraint_penalty <- constraint_penalty + log((sum(parent_data$ValueEUR)-250000000)^penalty)
  }
  if (sum(parent_data$WageEUR) > 250000) {
    constraint_penalty <- constraint_penalty + log((sum(parent_data$WageEUR)-250000)^penalty)
  }
  if (any(rating_list < 1.2)) {
    constraint_penalty <- constraint_penalty + 1.2^penalty
  }
  
  potential_minus_age
  
  target_value <- -(sumratings+0.3*sum(potential_minus_age) +sum(int_reputation))+constraint_penalty
  
  return(target_value)
}


#target(global_best)






parents<-pop_init
t_size=2
penalty=1

tournament_selection <- function(parents, t_size,penalty=6) {
  random_parents_idx <- sample(nrow(parents), t_size, replace = FALSE)
  random_parents <- parents[random_parents_idx, ]
  
  random_parents_fitness <- apply(random_parents, 1, function(x) target(x, penalty=penalty))
  
  
  best_parent_idx <- which.min(random_parents_fitness)
  return(random_parents[best_parent_idx, ])
}


tournament_selection (pop_init,t_size=2)


#best parent 1
#tournement_selection *50





corssover_point<-6

parent1<-row1
parent2<-pop_init[2,]



crossover <- function(parent1, parent2,corssover_point) {
  
  offspring1 <- c(parent1[1:crossover_point], parent2[(crossover_point + 1):ncol(parent1)])
  offspring2 <- c(parent2[1:crossover_point], parent1[(crossover_point + 1):ncol(parent2)])
  
  return(rbind(offspring1, offspring2))
  
}