From ee69659584d6a3428c394fbf9e560eeb450d0c78 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 14 Apr 2016 16:16:07 -0500 Subject: [PATCH 1/6] Move Shiny files to project root Can't reference legderr files unless they are within the Shiny app folder. This project gets weirder and weirder, will probably need to be split eventually. --- .../shinyapps.io/mattbk/ledgerr-shiny.dcf | 4 ++-- ledgerr-shiny/server.R => server.R | 0 ledgerr-shiny/ui.R => ui.R | 0 working.Rmd | 14 +++++++++++--- 4 files changed, 13 insertions(+), 5 deletions(-) rename {ledgerr-shiny/rsconnect => rsconnect}/shinyapps.io/mattbk/ledgerr-shiny.dcf (74%) rename ledgerr-shiny/server.R => server.R (100%) rename ledgerr-shiny/ui.R => ui.R (100%) diff --git a/ledgerr-shiny/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf b/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf similarity index 74% rename from ledgerr-shiny/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf rename to rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf index f69d82f..1e729d9 100644 --- a/ledgerr-shiny/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf +++ b/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf @@ -2,6 +2,6 @@ name: ledgerr-shiny account: mattbk server: shinyapps.io appId: 94541 -bundleId: 420068 +bundleId: 420069 url: https://mattbk.shinyapps.io/ledgerr-shiny/ -when: 1460668046.58897 +when: 1460668285.29384 diff --git a/ledgerr-shiny/server.R b/server.R similarity index 100% rename from ledgerr-shiny/server.R rename to server.R diff --git a/ledgerr-shiny/ui.R b/ui.R similarity index 100% rename from ledgerr-shiny/ui.R rename to ui.R diff --git a/working.Rmd b/working.Rmd index 39bbd1c..618ae03 100644 --- a/working.Rmd +++ b/working.Rmd @@ -17,9 +17,6 @@ library(gsheet) library(R.utils) #for sourceDirectory() sourceDirectory("ledgerr/R") -# For Shiny -library(rsconnect) - # Pull Google sheet locations from another file (journal1, journal2, etc.) source("config.R") @@ -65,4 +62,15 @@ a$Net<-rowSums(a[,2:3],na.rm=T) colSums(a[-1]) +``` + +```{r deploy} +# See Shiny documentation for authorizing computer to deploy to shiny.io. + +# For Shiny +library(rsconnect) + +# Deploy +deployApp() + ``` \ No newline at end of file From 69ef761628756eb362caf485a1ca7a6f4d028132 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 14 Apr 2016 17:08:05 -0500 Subject: [PATCH 2/6] Get some Shiny stuff going. --- config.template.R | 5 ++++- server.R | 41 +++++++++++++++++++++++++++++++++++++---- ui.R | 26 +++++--------------------- working.Rmd | 3 ++- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/config.template.R b/config.template.R index 5ac3f55..7e9e694 100644 --- a/config.template.R +++ b/config.template.R @@ -1,4 +1,7 @@ # Copy each of the sheets by URL (from address bar) # TODO return a list, not series of named variables journal1<-gsheet2tbl("https://docs.google.com/spreadsheets/morestuffhere1") -journal2<-gsheet2tbl("https://docs.google.com/spreadsheets/morestuffhere2") \ No newline at end of file +journal2<-gsheet2tbl("https://docs.google.com/spreadsheets/morestuffhere2") + +# Shiny.io application name +shiny.io<-ledgerr-shiny \ No newline at end of file diff --git a/server.R b/server.R index 340b2a6..fe6839c 100644 --- a/server.R +++ b/server.R @@ -2,13 +2,41 @@ # This is the server logic of a Shiny web application. You can run the # application by clicking 'Run App' above. # -# Find out more about building applications with Shiny here: -# -# http://shiny.rstudio.com/ -# library(shiny) +# Use https://github.com/maxconway/gsheet +library(gsheet) + +# Use the functions in ledgerr (the package that is part of this project) but don't load the package itself--this will let us deploy to Shiny.io more easily. +library(R.utils) #for sourceDirectory() +sourceDirectory("ledgerr/R") + +# Pull Google sheet locations from another file (journal1, journal2, etc.) +source("config.R") + +# Combine bank accounts +journal<-rbind(journal1,journal2) + +## Clean up +# Date is date +journal$Date<-as.Date(journal$Date,format="%m/%d/%Y") +# Replace empty classes and accounrs +journal$Class[journal$Class==""]<-c("unclassified") +journal$Account[journal$Account==""]<-c("unclassified") +# Class, Accounts are factors +journal$Class<-as.factor(journal$Class) +journal$Account<-as.factor(journal$Account) +# Empty class should be NA +# Debit and Credit are numeric, without commas +journal$Debit<-as.numeric(sub(",","",journal$Debit)) +journal$Credit<-as.numeric(sub(",","",journal$Credit)) + + + + + + # Define server logic required to draw a histogram shinyServer(function(input, output) { @@ -23,4 +51,9 @@ shinyServer(function(input, output) { }) + # Show journal + output$mytable = renderDataTable({ + journal + }) + }) diff --git a/ui.R b/ui.R index 8d34ddd..5475f96 100644 --- a/ui.R +++ b/ui.R @@ -10,24 +10,8 @@ library(shiny) # Define UI for application that draws a histogram -shinyUI(fluidPage( - - # Application title - titlePanel("Old Faithful Geyser Data"), - - # Sidebar with a slider input for number of bins - sidebarLayout( - sidebarPanel( - sliderInput("bins", - "Number of bins:", - min = 1, - max = 50, - value = 30) - ), - - # Show a plot of the generated distribution - mainPanel( - plotOutput("distPlot") - ) - ) -)) +shinyUI(basicPage( + h2('Journal'), + dataTableOutput('mytable') +) +) diff --git a/working.Rmd b/working.Rmd index 618ae03..b714f80 100644 --- a/working.Rmd +++ b/working.Rmd @@ -66,6 +66,7 @@ colSums(a[-1]) ```{r deploy} # See Shiny documentation for authorizing computer to deploy to shiny.io. +# TODO add complete steps here on how to set up and deploy # For Shiny library(rsconnect) @@ -73,4 +74,4 @@ library(rsconnect) # Deploy deployApp() -``` \ No newline at end of file +``` From 7cccaa2d703819f3a045e89ecd0cf9f6c9d1ed09 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 15 Apr 2016 14:05:49 -0500 Subject: [PATCH 3/6] Add shinyapps.io deployment instructions so I remember how. --- README.md | 14 +++++++++++++- config.template.R | 3 --- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c45d980..915e557 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,22 @@ R functions for single-entry-ish bookkeeping reports. Work in progress. -##Input format +## Input format Uses Google Sheets for data entry, R for reporting and analysis. |Date|Ref No.|Payee|Memo|Class|Debit|Credit|Bank|Reconciliation Status|Balance|Type|Account| |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- | +## Deployment to shinyapps.io + +Authorize your computer (run once): +`install.packages('rsconnect')` +`library(rsconnect)` +`rsconnect::setAccountInfo(name='', + token='', + secret='')` + + +Deploy from project root (run to update) +`deployApp()` diff --git a/config.template.R b/config.template.R index 7e9e694..8be8803 100644 --- a/config.template.R +++ b/config.template.R @@ -2,6 +2,3 @@ # TODO return a list, not series of named variables journal1<-gsheet2tbl("https://docs.google.com/spreadsheets/morestuffhere1") journal2<-gsheet2tbl("https://docs.google.com/spreadsheets/morestuffhere2") - -# Shiny.io application name -shiny.io<-ledgerr-shiny \ No newline at end of file From 347992c96813a2a649388ecdfc544e5073af79d5 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 15 Apr 2016 14:13:35 -0500 Subject: [PATCH 4/6] Temp commit. --- .gitignore | 3 ++- rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf | 4 ++-- working.Rmd | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f074bfb..a447d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .Rhistory .Rproj.user config.R -*.Rproj \ No newline at end of file +*.Rproj +/rsconnect \ No newline at end of file diff --git a/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf b/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf index 1e729d9..4a10bd1 100644 --- a/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf +++ b/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf @@ -2,6 +2,6 @@ name: ledgerr-shiny account: mattbk server: shinyapps.io appId: 94541 -bundleId: 420069 +bundleId: 421047 url: https://mattbk.shinyapps.io/ledgerr-shiny/ -when: 1460668285.29384 +when: 1460747248.16264 diff --git a/working.Rmd b/working.Rmd index b714f80..4451591 100644 --- a/working.Rmd +++ b/working.Rmd @@ -65,8 +65,7 @@ colSums(a[-1]) ``` ```{r deploy} -# See Shiny documentation for authorizing computer to deploy to shiny.io. -# TODO add complete steps here on how to set up and deploy +# See README.md # For Shiny library(rsconnect) From c9c8c709b84ba84d1867704287ffa69aa2a6bee0 Mon Sep 17 00:00:00 2001 From: mattbk Date: Fri, 15 Apr 2016 14:14:04 -0500 Subject: [PATCH 5/6] Delete ledgerr-shiny.dcf --- rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf diff --git a/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf b/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf deleted file mode 100644 index 4a10bd1..0000000 --- a/rsconnect/shinyapps.io/mattbk/ledgerr-shiny.dcf +++ /dev/null @@ -1,7 +0,0 @@ -name: ledgerr-shiny -account: mattbk -server: shinyapps.io -appId: 94541 -bundleId: 421047 -url: https://mattbk.shinyapps.io/ledgerr-shiny/ -when: 1460747248.16264 From edc87296a900de8169cfce959c230dd9ec00b5f8 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 15 Apr 2016 14:19:29 -0500 Subject: [PATCH 6/6] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a447d8f..799066f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ .Rproj.user config.R *.Rproj -/rsconnect \ No newline at end of file +rsconnect/ \ No newline at end of file