Dear group,

 

Here is my function :

 

 

 

position<-function(x) 

{

 

 
pose<-read.csv2((paste(c("LSCPos",x,".csv"),collapse="")),dec=".",sep=",",as
.is=T,h=T,skip=1)[,c(4,8,14,15)]

  pose$CREATED.DATE<-as.Date(pose$CREATED.DATE,"%d/%m/%y")              

  futures<-pose[-grep("USD",pose[,1]),]


  colnames(futures)<-c("CONTRAT","CREATED.DATE","QUANTITY","SETTLEMENT")

  lme<-pose[grep("USD",pose[,1]),]      

  lme$DESCRIPTION <- gsub(" *(\\d+/\\d+/\\d+) *$", "", lme$DESCRIPTION) 

  library(plyr)

  PositionFut<-ddply(futures, c("CONTRAT","SETTLEMENT"), summarise,
POSITION=sum(QUANTITY))[,c(1,3,2)]

  PositionLme<-unique(ddply(lme, c("DESCRIPTION"), summarise,
POSITION=sum(QUANITY),DATE=max(CREATED.DATE),SETTLEMENT=CLOSING.PRICE[CREATE
D.DATE == max(CREATED.DATE)]))[,-3]

 

 

  print(PositionFut)

  print(PositionLme)

 

}

  

As I'm totally new to this kind of sport, i.e. writing code, the code is
maybe ugly, but it does work. Now, one thing is missing.

 I want to have the 2 Dataframes "PositionFut" & "PositionLme" in my
environment, as I will need them later for another function. If I do a
save(), it will be saved in my directory, but won't see it when I do ls(),
even if I do a get() before. What is the process to save these 2 objects in
order to access them later in another function?

 

 

***************************

Arnaud Gaboury

Mobile: +41 79 392 79 56

BBM: 255B488F

***************************

 


	[[alternative HTML version deleted]]

