Airlines_Dataset <- function(Number_Of_Rows){
#Departure Date
day.start <- "2009/01/01"
day.end <- "2014/04/25"
Departure_Date <- function(day.start,day.end,size) { //Generates Random dates
dayseq <- seq.Date(as.Date(day.start),as.Date(day.end),by="day")
dayselect <- sample(dayseq,size,replace=TRUE)
Date <- dayselect
}
Date <- data.frame(Departure_Date(day.start,day.end,size=Number_Of_Rows))
return(Date)
#Origin
Origin_Func <- function(Number_Of_Rows,...){
Origin <- (sample(c('IND','ISP','JAN','JAX','IND','ISP',
'LAS','LAX','LBB','LIT','MAF','MCI','MCO','MDW','MHT',
'MST','MCO','OAK','OAC','OMA','OMT','ORF','PBI','PDX',
'PHL','PHX','PIT','PVD','RDU','RNO','RSW','SAN','SAT',
'SDF','SEA','SFO','SJC','SLC','SMF','SNA','STL','TPA',
'TUL','TUS','ABQ','IAD'),Number_Of_Rows, replace=TRUE))
Origin <- data.frame(Origin)
/*Given below is source code of origin*/
Origin_Exec <- system.time((sample(c('IND','ISP','JAN','JAX','IND','ISP',
'LAS','LAX','LBB','LIT','MAF','MCI','MCO','MDW','MHT',
'MST','MCO','OAK','OAC','OMA','OMT','ORF','PBI','PDX',
'PHL','PHX','PIT','PVD','RDU','RNO','RSW','SAN','SAT',
'SDF','SEA','SFO','SJC','SLC','SMF','SNA','STL','TPA',
'TUL','TUS','ABQ','IAD'),Number_Of_Rows, replace=TRUE)))
}
/*Some static origin codes that generates random strings from the list given above*/
return(Origin)
}
am calling the function as given below
Airlines_Result <- Airlines_Dataset(1000)
When I call the above functions only one function is invoked that is date and tine origin is not invoked.
Final Step is to combine the data frames
Airlines_Data <- data.frame(Origin,Date)
Anyone please help to execute the code in proper format I want origin and date to be present in single function call
return, so yours will be ending atreturn(Date). Maybe it will be easiest if you combine the data.frames inside the function and return that.