I have a dataframe created in R that is organized as follows:
> all_data[3945:3952,]
Date btc_close eth_close vix_close gold_close DEXCHUS
3945 2016-11-01 729.27 10.77 18.56 122.73 828
3946 2016-11-02 742.46 NA 19.32 123.64 826
3947 2016-11-03 687.51 NA 22.08 124.30 827
3948 2016-11-04 702.54 NA 22.51 124.39 824
3949 2016-11-05 704.16 NA NA NA NA
3950 2016-11-06 712.24 NA NA NA NA
3951 2016-11-07 704.02 NA 18.71 122.15 835
3952 2016-11-08 709.15 10.87 18.74 121.64 843
How can I add a new column that has 3 levels? The levels would be -1 for decrease, 0 for no change, and 1 for increase. This direction column should be based upon the previous days value for btc_close.
(Note- there will be many NA's- I would then like to subset the data according to only rows that have data for btc_close)