Normal distributions
/////////////////////////////////////
 Normal and student-t distribution are symmetric. 
 Normal distributions' density function is dnorm()
 ---------------------------------------------
  x<-seq(-3,3,0.1)
  y<-dnorm(x)       # for cumulative normal distribution is pnorm()
  plot(x,y)
  
/////////////////////////////////////

Normality test
/////////////////////////////////////

library(nortest)
set.seed(123)
a<-rnorm(100)

# Perform Anderson-Darling test
ad.test(a)

  Anderson-Darling normality test
data:  a
A = 0.182, p-value = 0.9104

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

cbind() VS. data.frame()
///////////////////////////

We might have an unexpected result when using the cbind() function to join columns with different types. 
> x<-as.Date("1990-01-02",format="%Y-%m-%d")
> y<-as.integer(format(x, "%Y"))
> data<-cbind(x,y)
> data
        x    y
[1,] 7306 1990
Next, we use the data.frame() function to combine two different data types.
> x<-as.Date(“1990-01-02”,format=”%Y-%m-%d”)
> y<-as.integer(format(x,”%Y”))
> data<-data.frame(x,y)
> data
           x    y
1 1990-01-02 1990
The cbind() function generates unexpected results because it will produce a matrix that requires all columns to have the same types, i.e., all numeric or all characters. 
> x<-2001
> y<-2009
> cbind(x,y)
        x    y
[1,] 2001 2009
When combining two data sets with one in a string format, both will end up with the same string format. 
> x<-“2001”
> y<-2009
> cbind(x,y)
     x      y     
[1,] “2001” “2009”
On the other hand, this is not true when applying the data.frame() function, as shown below. 
>  x<-"2001"
>  y<-2009
>  z<- data.frame(x,y)
>  print(z)
     x    y
1 2001 2009
> z$x
[1] "2001"
> z$y
[1] 2009
///////////////////////////

the attach() function
/////////////////////////////////

The attach() function makes columns available from a data set.  
	> y<-data.frame('ibm',matrix(0:9,5,2))
	> colnames(y)<-c("ticker","year","ret")
	> ticker                             # not available
	Error: object 'ticker' not found
	> attach(y)
	> ticker
	[1] ibm ibm ibm ibm ibm
	Levels: ibm
To make columns within a variable unavailable, we use the detach() function. 
	> detach(y)
	> ticker
	Error: object 'ticker' not found
	> a<- c(2.0, 0.3, 2.5) 
	> b<- c("ticker", "date", "ret") 
	> c<- c(T, T,FALSE) 
	> x<-data.frame(a, b,c)   
	> x
	    a      b     c
	1 2.0 ticker  TRUE
	2 0.3   date  TRUE
	3 2.5    ret FALSE
We use the merger() function to merge two data sets. 
	>z<-merge(stock,index,by="date")
/////////////////////////////////