Dear All, I have a data frame which is structured as follows:

COMPANY_NUMBER  COMPANY_NAME    CITY    YEAR_END_DATE   CLOSE_SHARE_PRICE
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2005      NA
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2006      NA
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2007      9.65
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2008      6.55
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2009      6.55
22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY         (THE)Egham      
30/09/2010      7.5
10395804        TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne     
30/11/2016      NA
10395804        TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne     
30/11/2017      1.04
10395804        TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne     
30/11/2018      1.04
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2000      NA
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2001      NA
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2003      NA
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2004      NA
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2005      NA
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2006      1.09
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2007      1.17
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2008      1.24
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2009      0.9
SC192761        MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLC        Edinburgh       
31/01/2010      1.14



I am trying to calculate the total change in share price like for CARDIFF 
PROPERTY PUBLIC LIMITED COMPANY the total change

between 2005 and 2006 is NA and for 2006 and 2007 it is NA for 2007 and 2008 it 
is -3.1 and 2008 and 2009 it is 0 and 2009 and 2010 it is +.95. 


I am trying to achieve this via he following code:

for (i in 1:(nrow(PLC)-1))
if (isTRUE (PLC[i, 1] == PLC[i + 1, 1]))
{
PLC$CH_SH_PRICE(i+1) = (PLC$CLOSE_SHARE_PRICE[i+1] -
PLC$CLOSE_SHARE_PRICE[i])
}


I get the following error


Error in 1:(nrow(PLC) - 1) : argument of length 0


Can you kindly suggest any solution to this issue?


Thanks in advance.
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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