Sequential merge with loop in R

I'm using the R-package for Quandl trying to create a data frame with stock quotes for a list of specified companies.

install.packages("Quandl")

library(Quandl)
library(reshape)

Quandl.auth("yourauthenticationtoken")

#create date structure (using AAPL)
structure <- Quandl("GOOG/NASDAQ_AAPL",start_date="2004-01-01",end_date="2013-12-31", collapse="weekly")[c(1)]

#list of stocks to fetch
stocks <- c("MSFT", "AAPL")

# Function to fetch stock quotes
rdQcurr <- function(curr){
    codes <- paste("GOOG/NASDAQ_",curr,sep="")
    for(i in 1:length(stocks)){
    df<-Quandl(codes[i],start_date="2004-01-01",end_date="2013-12-31", collapse="weekly")[c(1,2)]

    #rename coloumn 2 to the name of the stock 
    names(df)[2]<-paste(stocks[i])
    #merge i'th stock to structure data frame 
    structure <- merge(x=structure, y=df, by = "Date", all.x=TRUE)
}
} 

quotes <- rdQcurr(stocks) 

EDIT: This code does run, but the data frame "quotes" is NULL.

Any ideas on how to solve this problem?

Answers


please go through basic of R

rdQcurr <- function(curr){
    codes <- paste("GOOG/NASDAQ_",curr,sep="")
    for(i in 1:length(stocks)){
    df<-Quandl(codes[i],start_date="2004-01-01",end_date="2013-12-31", collapse="weekly")[c(1,2)]

    #rename coloumn 2 to the name of the stock 
    names(df)[2]<-paste(stocks[i])
    #merge i'th stock to structure data frame 
    structure <- merge(x=structure, y=df, by = "Date", all.x=TRUE)
}
 return(structure)
} 
> quotes <- rdQcurr(stocks) 
> quotes
          Date  MSFT
1   2004-01-04 27.58
2   2004-01-11 28.03
3   2004-01-18 27.72
4   2004-01-25 28.26
5   2004-02-01 27.84
---------------------

Need Your Help

WCF: Client-side Mutual Certificate Authentication Problem (Could not establish secure channel for SSL/TLS with authority)

wcf wcf-security wcf-client

I've done thorough research on my problem and have read many other posts/blogs but their solutions didn't solve mine. I was hoping someone could help.

Which error correction could should I use for GF(32)

error-correction reed-solomon forwarderrorcorrection

I searched for comparisons between Reed-Solomon, Turbo and LDPC codes but they all seem to focus on efficiency. I'm more interested in commercial license of available libs, easiness and GF(32), i.e...