Relative Content

Tag Archive for rdplyr

Projections in R dataframe

I have a R dataframe with year, growth_rate and total for one year. I want to fill missing values by discounting using the growth_rate with increase with years after and decrease for years before. For instance, if the year with value is 2018, the value for 2019 is value for 2018 multiplied by 2018 growth rate, the value for 2020 is value for 2018 multiplied by 2018 growth rate and growth_rate value for 2019. Conversely, the value for 2017, would be the value of 2018 discounted by the grotwh_rate of 2017, the value for 2016 would be the value of 2018 discounted by the grotwh_rate of 2017 and growth_rate for 2016. Below is the example dataframe with the desired column being total_projection

pmax (pmin) na.rm not working – Problem with NA/NaN Argument

I am dealing with a problem related to the pmax (and the pmin) function. I know it is used to get rowwise max (min) values. And what I wanted to get are the max and min values so to set some columns to a new range that is balanced for my analysis. The a:g is the old range and e:g is the new range that I want to use and balance out. My dataframe is not exactly the same (quite big actually), but for the sake of getting to the point, lets say the df is like this: