Get some Shiny stuff going.
This commit is contained in:
		@@ -2,3 +2,6 @@
 | 
			
		||||
# 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
 | 
			
		||||
							
								
								
									
										41
									
								
								server.R
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								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
 | 
			
		||||
  })
 | 
			
		||||
  
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								ui.R
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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')
 | 
			
		||||
)
 | 
			
		||||
)
 | 
			
		||||
))
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user