Using R to generate the SPI within the data set (SPEI package)

I am very new to R and have a simple question. I need to use the SPEI package and generate the Standardized Precipitation Index using a panel data set of (panel=310 and t=1900 to 2015). I follow the article “How to use: Package 'SPEI' for basic calculations”. I am able to replicate it with my data. This is the code that I run

SPI3 = spi(mydata$RF, scale = 3, distribution = 'Gamma')

I see my data listed in the ‘environment window’ on the top right and I see the SPI3 index listed below it. However, I need the index to be generated ‘within the data set’ as an additional variable. That is evidently not the case and I don’t know how to get the index in my dataset. I realize that I have probably not ‘defined’ the data set and/or the new variable to be included in it but can’t get how to do so.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.