path <- getwd()
isRunningInShiny <- Sys.getenv('SHINY_PORT') != ""
if(endsWith(path,'R') | isRunningInShiny){
source('Classes/MintClass.R')
source('Classes/ExpensesClass.R')
} else {
source('R/Classes/MintClass.R')
source('R/Classes/ExpensesClass.R')
}
setClass("Insights", slots =c(mint = "Mint",
expenses = "Expenses"),
prototype=list(
mint = NULL,
expenses = NULL
))
#Creator
Insights = function(mint,expenses) {
new("Insights",mint=mint,expenses=expenses)
}
setGeneric(name="categoryBeneficiaryExpenses",
def=function(object,inpBeneficiary)
{
standardGeneric("categoryBeneficiaryExpenses")
}
)
#' Join mint Data to Reconcile
#' @param object Insights object
#' @param Beneficiary Beneficiary to explore
#' @return data frame
setMethod(f="categoryBeneficiaryExpenses",
signature=c("Insights","character"),
definition = function(object,inpBeneficiary) {
clnTran <- subsetTransactions(object@expenses,chrWeeks="4")
#filter beneficiaries based on input
if(inpBeneficiary == "ALL")
benDs <- clnTran
else
benDs <- filter(clnTran,Beneficiary == inpBeneficiary)
agg <- group_by(benDs, Category,Beneficiary) %>%
summarize(Total = sum(trTotal))
sel <- select(agg, Beneficiary, Category, Total)
ord <- arrange(sel, Total, Category, Beneficiary )
ord
})
setGeneric(name="categoryExpenses",
def=function(object,inpBeneficiary)
{
standardGeneric("categoryExpenses")
}
)
#' Join mint Data to Reconcile
#' @param object Insights object
#' @param Beneficiary Beneficiary to explore
#' @return data frame
setMethod(f="categoryExpenses",
signature=c("Insights","character"),
definition = function(object,inpBeneficiary) {
clnTran <- subsetTransactions(object@expenses,chrWeeks="4")
#filter beneficiaries based on input
if(inpBeneficiary == "ALL")
benDs <- clnTran
else
benDs <- filter(clnTran,Beneficiary == inpBeneficiary)
agg <- group_by(benDs, Category) %>%
summarize(Total = sum(trTotal))
sel <- select(agg, Category, Total)
ord <- arrange(sel, Total, Category )
ord
})
setGeneric(name="BeneficiaryExpenses",
def=function(object,inpBeneficiary)
{
standardGeneric("BeneficiaryExpenses")
}
)
#' Join mint Data to Reconcile
#' @param object Insights object
#' @param Beneficiary Beneficiary to explore
#' @return data frame
setMethod(f="BeneficiaryExpenses",
signature=c("Insights","character"),
definition = function(object,inpBeneficiary) {
clnTran <- subsetTransactions(object@expenses,chrWeeks="4")
#filter beneficiaries based on input
if(inpBeneficiary == "ALL")
benDs <- clnTran
else
benDs <- filter(clnTran,Beneficiary == inpBeneficiary)
agg <- group_by(benDs, Beneficiary) %>%
summarize(Total = sum(trTotal))
sel <- select(agg, Beneficiary, Total)
ord <- arrange(sel, Total, Beneficiary )
ord
})
setGeneric(name="categoryTotalExpenseOutput",
def=function(object)
{
standardGeneric("categoryTotalExpenseOutput")
}
)
#' Join mint Data to Reconcile
#' @param object Insights object
#' @param Beneficiary Beneficiary to explore
#' @return data frame
setMethod(f="categoryTotalExpenseOutput",
signature=c("Insights"),
definition = function(object) {
clnTran <- subsetTransactions(object@expenses,chrWeeks="4")
agg <- summarize(clnTran,Total = sum(trTotal))
sel <- select(agg, Total)
ord <- arrange(sel, Total )
ord
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.