Hello!

I was trying to splice two wholesale price index deflators series which
have different base years. One of them is called wpi_def_nic2004(from 2005
to 2012), and another is called wpi_def_nic2008(from 2012 to 2019). I am
trying to create a single series such that the base year prices are
consistent with wpi_def_nic2008. The common year is 2012, which is used for
starting the splicing.

I would like to keep the values in the nic2008 series unchanged. The
nic2004 starts in 2005, and I would like to make the nic2004 series
consistent with nic2008. Moreover, I need to do this for each 2 digit
industry. I tried the following code, *but the problem I encounter is that
R only splices the nic2004 series only for the year 2011.* It does not
understand from my code that it can use the spliced value of 2011 in the
nic2004 series to go further back in the nic2004 series to splice the
remaining values from 2005-2011. This is the code I am using:

 merged <- full_join(wpi_def_nic2004,wpi_def_nic2008)

merged <- merged |> group_by(IND_CD_2D) |>
  mutate(spliced = case_when(year >= 2012 ~ def_value_nic2008,
                             year <= 2011 ~

 def_value_nic2004*(lead(def_value_nic2008)/lead(def_value_nic2004))))

Thanks a lot!
Manya

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