[R] help with xy.coords(x,y)

adamshun discoveryonthemars at hotmail.com
Tue Jun 19 03:53:44 CEST 2012


i am working on the project to analyze hedge fund performance, i would
appreciate that if you guys could spare some time helping me out with the R
code. Thanks.
 
The senario is:
 
i applied BOXPLOT() to plot the performance of all hedge funds with 7
strategies.

And right now in this boxplot I need to plot the points of 30 individual
hedge funds from my portfolio. And I applied POINTS() and TEXTXY() to label
these points.

There are 30 funds in my portfolio with 7 different strategies. 

"FundName"(fundNames), "fundStrats", "Return"(fundrets)


Here is my code:

for(i in 1:T){                   
# T equals to the amount of strategies in my portfolio 

strat = portStrats[i];            
#get strategy  

portidx = fundStrats == strat;  
# identify portfolio funds of the same strategy


frets = fundrets[portidx];
fnames = fundNames[portidx];  
#get returns and names,” frets”: fund return, “fnames”:fund name

N = length(frets);

s = 1 / N;                   #now figure out where to put the labels
for (j in 1:N){
yy = j * s + i*1;
points(x=frets[j],y=yy,col="red");
textxy(X=frets[j],Y=yy,labs=fnames[j]); 
}

}

Right now the question is that, The ERROR is Error in xy.coords(x, y) : 'x'
and 'y' lengths differ.
So how to fix it?
 
Thank you so much.

Adam

--
View this message in context: http://r.789695.n4.nabble.com/help-with-xy-coords-x-y-tp4633785.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list