Dear R helpers,

I have two input files as 'quantity.csv' and 'equity_price.csv' as (for 
example) given below.

'quantity.csv'
GOOG     YHOO
1000         100


'equity_price.csv'
sr_no   GOOG_price           YHOO_price
1            15.22                 536.40
2            15.07                 532.97
3            15.19                 534.05  
4            15.16                 531.86 
5            15.11                 532.11

My problem is to calculate the portfolio value for each of these 5 days 
(actually my portfolio 
consists of 47 comanies and prices taken are for last 1 year).

I had defined 

X = read.csv('quantity.csv')
Y = read.csv('equity_price.csv')

I have tried the loop 

Z = array()

for (i in 1:2)
{
Z[i] = (X[[i]]*Y[i])
}

# When I write this dataframe as

write.csv(data.frame(Z), 'Z.csv', row.names = FALSE)

When I open 'Z.csv' file, I get

c.2500L..3300L..4500L..1000L..4400L.    
c.14000L..45000L..48000L..26000L..15000L.
2500    14000
3300    45000
4500    48000
1000    26000
4400    15000

My requirement is to have the column heads and the portfolio total as
GOOG        YHOO     Total
2500           14000     16500
3300           45000     48300
4500           48000     52500
1000           26000     27000
4400           15000     19400


Please guide

Regards

Sarah




      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to