From 79c5be63728e99f6d427f2a72fc557eeab3e8455 Mon Sep 17 00:00:00 2001 From: yueguoguo Date: Fri, 24 Mar 2017 13:26:13 +0800 Subject: [PATCH] Avoided join message and reordered columns --- R/expenseCalculator.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/expenseCalculator.R b/R/expenseCalculator.R index 5e26ae4..dc784f0 100644 --- a/R/expenseCalculator.R +++ b/R/expenseCalculator.R @@ -339,12 +339,18 @@ expenseCalculator <- function(context, df_used_rates <- filter(df_rates, MeterId %in% meter_list) %>% rename(meterId=MeterId) + + # invisible(capture.output(df_cost <- left_join(df_used_data, df_used_rates))) df_cost <- - left_join(df_used_data, df_used_rates) %>% + left_join(df_used_data, df_used_rates, by="meterId") %>% mutate(Cost=totalQuantity * MeterRate) %>% select(-IncludedQuantity, -EffectiveDate, -MeterStatus, -usageStartDate, -usageEndDate, -meterId, -MeterRegion) %>% na.omit() + + # reorder columns. + + df_cost <- df_cost[, c(3, 2, 4, 1, 5, 6, 7)] df_cost }