Thanks Rui, but this does not change the value in the new column
automatically if I change the value in the data column. Any ideas?

Regards,
Ankur Seth


On Sat, Sep 7, 2013 at 2:11 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:

> Hello,
>
> Try the following.
>
> dat <- read.table(text = "
>
> Date                                Value
> 08/01/2013                        100
> 08/02/2013                         100.5
> 08/03/2013                         102
> ", header = TRUE)
>
>
> dat$New <- c(NA, diff(dat$Value))
> dat
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 07-09-2013 06:06, Ankur Seth escreveu:
>
>> Hello All,
>>
>> I am trying to build a model in R. I am facing the following problem...
>>
>> My Data Frame contains the following data...
>>
>> Date                                Value
>> 08/01/2013                        100
>> 08/02/2013                         100.5
>> 08/03/2013                         102
>> ....
>>
>> Now I want to add a column to this data frame where New Column Value =
>> Difference of two subsequent observations. For Eg. on 08/02/2013 the new
>> value = 100.5 - 100=0.5
>>
>> I want to do this dynamically such that if I change the value in Value
>> column the new column should recalculate automatically.
>>
>> Is there a way to do this in R?
>>
>> Regards,
>> Ankur Seth
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>


-- 
Regards,
Ankur Seth

        [[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