From 881c635ad7f0f36b2ccd859c09786835d2d7f96e Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 14 Apr 2016 17:08:05 -0500 Subject: [PATCH] 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 +```