memory.limit()
memory.size(max = TRUE)
rm(list=ls(all=T))
library(MARSS)
library(ggplot2)
library(reshape2)
library(data.table)
data <- rbind(data1, data2, data3, data4, data5, data6, data7, data8, data9, data10, data11, data12)
data$group <- as.factor(data$group)
data<- transform(data, group = factor(group))
data <- transform(data, group = reorder(group, rank(group)))
saveRDS(data, file="data.Rds")
Shiny.R
library(shiny)
setwd("consumer journey");
runApp("Shiny")
ui.R
library(shiny)
# Define UI for dataset viewer application
shinyUI(fluidPage(
titlePanel("Summary Statistics"),
sidebarLayout(
sidebarPanel(
# Copy the line below to make a text input box
textInput("text", label = h3("Please enter column id"), value = "1"),
hr(),
dataTableOutput('mytable')),
mainPanel(
h3(textOutput("caption")),
h3("Positive:"),
verbatimTextOutput("summary1"),
h3("Users:"),
verbatimTextOutput("summary2"),
h3("Response Rates:"),
verbatimTextOutput("summary3"),
plotOutput("plot")
)
)
))
server.R
library(shiny)
library(ggplot2)
setwd("consumer journey");
data <- readRDS("shiny/data/data.Rds")
shinyServer(function(input, output) {
# You can access the value of the widget with input$text, e.g.
# output$value <- renderPrint({ input$text })
# Create a reactive text
text <- reactive({
paste(input$text)
})
output$caption <- renderText({
dat1 <- data[data$id==as.integer(text()),]
dat1$col[1]
})
output$mytable = renderDataTable({
dat1 <- data[data$id==as.integer(text()),]
})
output$summary1 <- renderPrint({
dat1 <- data[data$id==as.integer(text()),]
summary(dat1$positives)
})
output$summary2 <- renderPrint({
dat1 <- data[data$id==as.integer(text()),]
summary(dat1$users)
})
output$summary3 <- renderPrint({
dat1 <- data[data$id==as.integer(text()),]
summary(dat1$rr)
})
# Generate a plot of the requested variables
output$plot <- renderPlot({
dat1 <- data[data$id==as.integer(text()),]
dat1 <- dat1[1:min(50,nrow(dat1)),]
dat2<-dat1
dat2$group <- factor(dat2$group, levels=dat1$group)
p <- ggplot(dat2,aes(x=group, y=rr),environment=environment()) +
geom_bar(stat = "identity", fill = "blue") +
ggtitle("Distribution") +
ylab("First 50 Groups") + xlab("Group") +
theme(plot.title = element_text(face = "bold", size = 20)) +
theme(axis.text.x = element_text(face = "bold", size = 16)) +
theme(axis.text.y = element_text(face = "bold", size = 16)) +
theme(axis.title.x = element_text(face = "bold", size = 16)) +
theme(axis.title.y = element_text(face = "bold", size = 16, angle = 90))
print(p)
})
})