Grokbase Groups R r-help June 2012
FAQ
Hi guys,

I am doing a project to evaluate the 7 individual fund performance from a
portfolio compared with all fund performance utilizing the same strategy.

Lets say in total there are 10 strategies and in the portfolio there exist 5
strategies.

First, i use the BOXPLOT() and SUBSET() to produce the box plot of all the 5
funds performance individually:

#identify funds in strategies within the portfolio
filteredFunds = subset(allfunds,Strategy %in% portStrats);

#create box plot
boxplot(NetReturn~Strategy,data=filteredFunds,horizontal=TRUE)

Though it produced these 5 box plot, while the Y-aix has all the 10 strategy
labels.
*So the FIRST QUESTION is how to eliminate the other 5 strategies on the
Y-aix? *

Next, I used the POINTS() to plot the performance of specific funds in the
related box plot, which are from the portfolio.
and used TEXTXY() to label its name.

#label portfolio funds

for(i in 1:T){
#loop through all strategies

#get strategy
strat = portStrats[i];

#identify all funds of that strategy
idx = allFundStrats == strat;

#get returns of the all funds
rets = allFundRets[idx];

#identify portfolio funds of the same strategy

portidx = fundStrats == strat;
#get returns and names
frets = fundrets[portidx];
fnames = fundNames[portidx];

N = length(frets);

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

}

*The ERROR is Error in xy.coords(x, y) : 'x' and 'y' lengths differ*
I think its because of the number of X&Y differs.

Can you guy help me to fix it?

Thank you so much.

--
View this message in context: http://r.789695.n4.nabble.com/Help-for-boxplot-tp4633325.html
Sent from the R help mailing list archive at Nabble.com.

Search Discussions

  • S Ellison at Jun 14, 2012 at 2:29 pm

    -----Original Message-----
    First, i use the BOXPLOT() and SUBSET() to produce the box
    plot of all the 5 funds performance individually:
    ...
    *So the FIRST QUESTION is how to eliminate the other 5
    strategies on the Y-aix? *
    either use
    boxplot(NetReturn~factor(Strategy),data=filteredFunds,horizontal=TRUE)
    # factor() will drop levels from an existing factor with surplus levels

    or use droplevels on your subset to remove the extra levels (assuming, of course, that you won't need them again).
    *******************************************************************
    This email and any attachments are confidential. Any use...{{dropped:8}}

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedJun 14, '12 at 4:21a
activeJun 14, '12 at 2:29p
posts2
users2
websiter-project.org
irc#r

2 users in discussion

S Ellison: 1 post Adamshun: 1 post

People

Translate

site design / logo © 2023 Grokbase