From 7712168b2d02f8ab03fa4c3c7f45f27c3fb06811 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 12 Apr 2016 23:12:34 -0500 Subject: [PATCH] snapshot --- working.Rmd | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/working.Rmd b/working.Rmd index b17adef..51a97e5 100644 --- a/working.Rmd +++ b/working.Rmd @@ -34,8 +34,8 @@ journal$Debit<-as.numeric(sub(",","",journal$Debit)) journal$Credit<-as.numeric(sub(",","",journal$Credit)) ## Temp function location -# All time net, takes journal and class name(s) as an argument -# TODO add date selection, take two dates only e.g., c("2015-01-01","2015-12-31") and test first +# TODO learn where to store functions +# net() function, takes journal, class name(s), and date range as arguments net<-function(journ,classselect="all",dates="all"){ if("all" %in% classselect) { classselect<-levels(journ$Class) @@ -65,6 +65,35 @@ for (i in 1:length(classes)) # Add total net row net.byclass[nrow(net.byclass)+1,]<-c("Total",net(journal)) + +# work in progress ############### + +# Net by class and date range +# TODO should be function that uses the net function above +# List of classes +classes<-levels(journal$Class) +# Set up data frame +net.byclass<-data.frame(Class=character(), + Net=numeric(), + stringsAsFactors=FALSE) +# Loop through classes, calculate net, and add to data frame +for (i in 1:length(classes)) +{ net.byclass[i,] <- c(as.character(classes[i]), + net(journal, + classes[i], + "all"), + na.rm=T) +} +# Add total net row +net.byclass[nrow(net.byclass)+1,]<-c("Total",net(journal)) + +############## + + + + + + # See other reports in QB and Ledger ``` \ No newline at end of file