An illustration
////////////////////////////////

Let’s use a simple example to explain the above concepts. Assume that we have 
   a set of values of 1,2,3 up to 5000. For a randomly chosen value, we can
   write a for() loop to search all data sets, i.e., from 1 to 5000. This is
   called sequential search. If repeating our search many times, on average for 
   each value we will run our loop 2,500 times. Let’s see how to apply a binary
   search. 

Assume that we choose a vale of 500. As the first step, we calculate
   midpoint 2500, i.e., as.integer((1+5000)/2). Since our value is less
   than the midpoint (500<2500), we drop up part (from 2500 to 5000).
   With just one comparison, we drop half our data set. 

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

Merging two data sets: library(dplyr)
///////////////////////
  library(dplyr)
  x<-1:10
  y<-letters[1:10]
  data1<-data.frame(y,x)
  colnames(data1)<-c("ID","item1")
  
  set.seed(123)
  x<-rnorm(6)
  y<-letters[2:7]
  data2<-data.frame(y,x)
  colnames(data2)<-c("ID","item2")

  leftJoin  <-data1 %>% left_join(data2,by='ID')   
  rightJoin <-data1 %>% right_join(data2,by='ID')   
  innerJoin <-data1 %>% inner_join(data2,by='ID')   
  fullJoin  <-data1 %>% full_join(data2,by='ID')   

  # right_join format: 
  new<-dataset1 %>% right_join(dataset2,by=c('column1','column2')

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

fv annuity example [new]
////////////////////////////
  Mary will deposit $100 every year for the next 5 years. 
     The first cash flow  happens at the end fo the first year. 
     What is the future value at the end of year 4?
     Assume that the discount rate is 10% per year?

          100     100     100      100
   |-------|-------|-------|--------|
   0       1       2       3        4 
   
   Method I: > c<-100
             > r<-0.1
             > n<-4
             > c/r*((1+r)^n-1)
              [1] 464.1

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

///////////////////////
A tibble is a modern version of a data frame in R, provided by the `tibble` package,
    which is part of the tidyverse collection of packages. Tibbles aim to improve the data frame by:

1. Enhanced Printing: Tibbles have a concise and informative print method, showing only
    the first ten rows and the columns that fit on the screen, which helps in handling large datasets.

2. Strict Subsetting: Tibbles do not automatically convert strings to factors and do
    not change the types of variables when subsetting.

3. Better Error Messages: They provide more informative error messages, making debugging easier.

4. Column Names Handling: Tibbles support non-syntactic names and do not force the 
    column names to be valid R variable names.

These features make tibbles particularly useful for data analysis and manipulation in R, 
   enhancing the usability and readability of the data frames.

library(tibble)
my_tibble <- tibble(
    x = 1:5,
    y = c("a", "b", "c", "d", "e"),
    z = x * 2
)
print(my_tibble)

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