more tibble examples
///////////////////////

library(tibble)

# Create a tibble
my_tibble <- tibble(
  x = 1:5,
  y = c("a", "b", "c", "d", "e"),
  z = x * 2
)
# Subsetting a tibble by column names
subset_tibble <- my_tibble[, c("x", "y")]
print(subset_tibble)


# -----------------------------------
library(tibble)

# Create a tibble with non-syntactic names
non_syntactic_tibble <- tibble(
  'Column 1' = 1:3,
  'Column 2' = c("x", "y", "z")
)
print(non_syntactic_tibble)

///////////////////////

factor
///////////////////////
We can use the following functions: 
   is.factor(x)
   is.ordered(x)

   as.factor(x)
   as.ordered(x)

    https://www.rdocumentation.org/packages/base/versions/3.6.1/topics/factor

///////////////////////

%>% and group_by() function
///////////////////////

library(dplyr)
x <- data.frame(
Person= c("Alice", "Bob", "Carol", "Dave", "Eve", "Frank"),
  Region = c("North", "South", "North", "East", "South", "East"),
  Sales = c(250, 300, 150, 200, 350, 180)
)
total_sales_by_region <- x %>%
          group_by(Region) %>%
          summarize(TotalSales = sum(Sales))
#
///////////////////////

R program
////////////////////////////////

binary_search <- function(arr, target) {
  left <- 1
  right <- length(arr)
  i<-1
  while (left <= right) {
    i<-i+1
    mid <- floor((left + right) / 2)
    if (arr[mid] == target) {
       return(c(mid,i))  # Target found, return index
    } else if (arr[mid] < target) {
       left <- mid + 1  # Search the right half
    } else {
       right <- mid - 1  # Search the left half
    }
  }
  return(-1)  # Target not found
}

arr <- 1:5000 # Create a sorted array from 1 to 5000
target <- 700 # Define the target value
index <- binary_search(arr, target)

if (length(index)>1) {
   cat("Value", target, "found at index", index, "\n")
} else {
   cat("Value", target, "not found in the array\n")
}
///////////////////////////////

filter() function
///////////////////////

library(dplyr)
x<- data.frame(
  Name=c("Orange","Apple","Lemon","Banana","Grapefruit"),
  Type = c("Citrus","Pome","Citrus","Berry","Citrus"),
  Price = c(1.00, 1.50, 0.75, 0.50, 1.25)
)
cheap_fruits <- x%>%
    filter(Price < 1.00)
print(cheap_fruits)
    Name   Type Price
1  Lemon Citrus  0.75
2 Banana  Berry  0.50

///////////////////////