Created
          April 10, 2023 00:22 
        
      - 
      
- 
        Save catorch/e11eae4283db753ff6a9a909070e26b5 to your computer and use it in GitHub Desktop. 
    Short R Requirement
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Install and load the progress package | |
| if (!requireNamespace("progress")) install.packages("progress") | |
| library(progress) | |
| # Generate datasets with different ticket types and status | |
| set.seed(456) | |
| tickets1 <- data.frame(TicketType = sample(c("Type A", "Type B", "Type C", "Type D"), size = 100, replace = TRUE), | |
| Status = sample(c("Open", "Closed"), size = 10, replace = TRUE)) | |
| set.seed(42) | |
| tickets2 <- data.frame(TicketType = sample(c("Type A", "Type C", "Type E", "Type F"), size = 100, replace = TRUE), | |
| Status = sample(c("Open", "Closed"), size = 10, replace = TRUE)) | |
| # Get unique ticket types in both datasets | |
| unique_types1 <- unique(tickets1$TicketType) | |
| unique_types2 <- unique(tickets2$TicketType) | |
| # Check for missing types in dataset2 | |
| missing_types <- setdiff(unique_types1, unique_types2) | |
| # If there are missing types, prompt for Status values | |
| if (length(missing_types) > 0) { | |
| # Initialize progress bar | |
| pb <- progress_bar$new( | |
| format = "[:bar] :percent :current/:total :elapsed ETA: :eta", | |
| total = length(missing_types), | |
| clear = FALSE | |
| ) | |
| for (i in missing_types) { | |
| status <- readline(prompt = paste("Status for TicketType", i, ": ")) | |
| # Check if the entered status is valid (Open or Closed) | |
| while (status != "Open" && status != "Closed") { | |
| status <- readline(prompt = paste("Please enter a valid status (Open or Closed) for TicketType", i, ": ")) | |
| } | |
| # Add the missing TicketType and Status to dataset2 | |
| new_row <- data.frame(TicketType = i, Status = status) | |
| tickets2 <- rbind(tickets2, new_row) | |
| # Increment progress bar | |
| pb$tick() | |
| } | |
| # Save the updated dataset2 | |
| write.csv(tickets2, "tickets2_updated.csv", row.names = FALSE) | |
| } else { | |
| cat("All ticket types are present in tickets2.") | |
| } | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment