String variable 
///////////////////////////////
We could use a pair double quotation marks or a 
   pair single quotation marks to circle a string. 
   
  firstName<-"John"
   
  companyName<-'International Business Machine'

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

remove a variable or several variables or all 
////////////////////////////////
To remove all variables, we issue the following codes

    >rm(list=ls())

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

4-stock portfolio 
///////////////////////////////////////////////////////////////////////////////

 The four stocks in my portfolio are International Business Machine, Apple Incorporation, 
 Walmart, and Jonson & Johnson. If I have 100, 200, 230, and 500 shares of them, please give me an R
 program to estimate their portfolio returns. You can use the Python yfinance package to get their historical price data.  

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

deleting the first return
///////////////////////////////////////////////////////////////////////////////

Prompt: We are given a set of historical price data for multiple stocks. The data set is sorted by stock and date. 
   After calculating returns, each stock's first return should be a missing code since there is no price before 
   that date. The related prompt is given below. 

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

current working directory 
////////////////////////////////
To find out the current working directory, we use getwd()

  >getwd()

To change the current working directory, we use setwd()

  >setwd("c:/temp")

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

put several command lines together
////////////////////////////////

  We use semicolon to separate them

     > x<-10;y<-20         # several commands together           

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

the simplest function 
////////////////////////////////
Here is one line function for the present value

 Example #1: double any input value

       dd=function(x)2*x

   dd is the function name
   function is the keyword
   x in the parentheses is the input value
   2*x is the output put

    > dd(2.3)
      [1] 4.6

 Example #2: 

  >pv_function<-function(fv,r,n)fv/(1+r)^n

  >pv_funtion(100,0.1,1)

   [1] 90.90909

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