Binary files
////////////////////////////////
Binary files	RData 	save()

save.image()

	rds	saveRDS()

	xls, xlsx	See Chapter 12: R and Excel

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

writeRDS()
////////////////////////////////
 The writeRDS() functio is used to write a single R object to a file. 

 Example #1: # write to a c:/temp/test.rds
            a<-1:100
            saveRDS(a, "c:/temp/test.rds")

 Example #2: # write to a temp file 
            a<-1:100
            myFile<- tempfile("test", fileext = ".rds")
            saveRDS(a, myFile)

 Example #3
           > pv<-100
           > r<-0.1
           > n<-5
           > saveRDS(pv,r,n,"c:/temp/test2.rds")
           Error in saveRDS(pv, r, n, "c:/temp/test2.rds") : bad 'file' argument

           # Compare 
           save(pv,r,n,file="c:/temp/test2.rds")

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

save.image()
////////////////////////////////

we can use the save.image() to save everything to
    a RData data set. 

 In addition, we can use the load() function to load it. 

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

save.image() function 
////////////////////////////////

rm(list=ls(all=T))   # remove everything

source('http://datayyy.com/fmr/week1.txt')

save.image('weeek1.RData')

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

Download SEC zip fils from datayyy.com
///////////////////////////////////////////////////////

 Step 1: manuall download one zip file
         http://datayyy.com/sec/
  
        infile='http://datayyy.com/sec/y1993/QTR1/company.zip'
       > .is404(infile)  
         [1] 200

 Step 2: write a Python program to download
        from download import download
        infile='http://datayyy.com/sec/y1993/QTR1/company.zip'
        outfile='index1993q1.zip'
        download(infile,outfile)


 step 3: generate two variable called y and q
         y=1993
         q=2
        from download import download
        infile='http://datayyy.com/sec/y'+y+'/QTR'+q+'/company.zip'
        outfile='index'+y+'q'+q+'.zip'
        download(infile,outfile)

        # note str() function

 Step 4: one loop

 Step 5: double loops

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