Try to search your question here, if you can't find : Ask Any Question Now ?

how to set value for whole row through pipe function

HomeCategory: stackoverflowhow to set value for whole row through pipe function
john asked 1 week ago

I am trying to set the default value for the first row in of the data frame to 1 through the pipe function. As its one of the requirements to dynamically compound the values in the data with the date function. I will appreciate if anyone can help me to understand how I can set the default value for all the 1st rows in below mentioned code. I already created a placeholder where I m expected default value .

df2 <- df %>% mutate(MonthDate = as.Date(df$StartMonth,"%m/%d/%Y")) %>%
  filter(MonthDate > as.Date("2005-09-30"))%>%
  # Place holder where I want to set first row of the column to default value of 1#
  mutate(SAABenchmark_VAMI = cumprod(exp(SAABenchmarkstdev)),
         SAABetaOnly_VAMI = cumprod(exp(SAABetaOnly_stdev)),
         HFbenchmark_VAMI = cumprod(exp(HFbenchmarkReturns)),
         ZAAMHF_VAMI = cumprod(exp(ZAAMHFReturns)))%>%
  mutate(SAABenchmark_logVAMI =log(SAABenchmark_VAMI),
         SAABetaOnly_logVAMI=log (SAABetaOnly_VAMI),
         Hfbenchmark_logVAMI=log(HFbenchmark_VAMI),
         ZAAMHF_logVAMI=log(ZAAMHF_VAMI))%>%
  select(MonthDate,SAABenchmark_VAMI:ZAAMHF_logVAMI)%>%
  melt(., id.vars = "MonthDate")
1 Answers
Best Answer
Mannu answered 1 week ago
Your Answer

12 + 8 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com