How to import output from R to an Excel File -


stock_reco<- read.csv("c:\\temp\\migration.csv") migrate<-as.matrix(stock_reco) title<-colnames(migrate) dt1<-migrate[,3] dt2<-as.date(dt1, format= "%d/%m/%y") reco1<-migrate[,6] reco<-as.matrix(reco1) for(i in 1:4099) {   if((migrate[i,1]== migrate[i+1,1]) && (migrate[i,2]== migrate[i+1,2]))     {        k<-difftime(dt2[i+1],dt2[i],units = "days")        if((k <=180) && (reco[i] == reco[i+1]))        print (migrate[i,])        print (migrate[i+1,])        print ("----------------------------------------------------")      }  } 

last 2 print statements give final output in image attached below. want whole final output in excel file. how import output r excel file? want output in form

comp name brokerage house date cmp target recomendation yes bank motilal oswal 14/6/2011 294 420 buy yes bank motilal oswal 22/9/2011 285 400 buy

the above 1 set if conditions satisfied , there several such pairs. need of these in excel sheet. when run code in zig zag/ random form in r there no errors in code. please let me know how write output excel sheet in detail. thanks

@iceiceice try this

stock_reco<- read.csv("c:\\temp\\migration.csv") migrate<-as.matrix(stock_reco) title<-colnames(migrate) dt1<-migrate[,3] dt2<-as.date(dt1, format= "%d/%m/%y") reco1<-migrate[,6] reco<-as.matrix(reco1) (i in 1:4099) {   if((migrate[i,1]== migrate[i+1,1]) && (migrate[i,2]== migrate[i+1,2]))     {        k<-difftime(dt2[i+1],dt2[i],units = "days")        if((k <=180) && (reco[i] == reco[i+1]))        d <- rbind(d, data.frame(migrate[i,], migrate[i+1,]))         }     }  write.csv(file=filename, x='d')   

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -