Selected a CRM Analytics Example that looks at CD Sales Data in 1997 Code Pre-processes data in global.R file The app represents the distribution of sales amounts and allows the user to explore mean sales values
Joel Polanco
Hit <- or -> Arrows to Navigate
Selected a CRM Analytics Example that looks at CD Sales Data in 1997 Code Pre-processes data in global.R file The app represents the distribution of sales amounts and allows the user to explore mean sales values
The ui.R code captures User input for different levels of Mu (mean sales) as numeric values.
shinyUI(pageWithSidebar(
headerPanel("Example plot"),
sidebarPanel(
sliderInput('mu', 'Guess at the mu',value = 70, min = 60, max = 80, step = 0.05,) ),
mainPanel(
plotOutput('myHist')
)
))
The Server.R code calculates the mean square error at different values of Mu
hist(df$Amount, xlab='Purchase Amount', col='lightblue',main='Histogram')
mu <- input$mu
lines(c(mu, mu), c(0, 200),col="red",lwd=5)
mse <- mean((df$Amount - mu)^2)
text(300, 1500, paste("mu = ", mu))
text(300, 1900, paste("MSE = ", round(mse, 2)))
)
))
The global R code file loads and preps the data for the Ui and Server Files
# read CDNOW_SAMPLE.txt
df <- read.table("data/CDNOW_sample.txt",header=F,stringsAsFactors = FALSE)
# construct a data frame with the necessary columns of customer ID, transaction date, and money amount paid by a customer per transaction
df <- as.data.frame(cbind(df[,1],df[,3],df[,5]))
# add appropriate column names for the above three column and
names <- c("ID","Date","Amount")
names(df) <- names