Skip to content

Instantly share code, notes, and snippets.

@madonius
Created July 6, 2016 18:05
Show Gist options
  • Save madonius/da3f28352d184889b90cf626c1726467 to your computer and use it in GitHub Desktop.
Save madonius/da3f28352d184889b90cf626c1726467 to your computer and use it in GitHub Desktop.
Getraenkeanalyse für die Entropiadaten
data <- read.csv('transactions.csv', sep=';', header=TRUE)
data$timestamp<-as.POSIXct(as.numeric(as.character(data$timestamp)),origin='1970-01-01',tz='GMT')
#select the data relevant to the income
clubmate <- subset(data, product=='clubmate')
floramate <- subset(data, product=='floramate')
clubcola <- subset(data, product=='clubmate-cola')
eichbaum <- subset(data, grepl('eichbaum',product))
karamalz <- subset(data, product=='karamalz')
h_total <- hist(data$timestamp, breaks='days', plot=FALSE)
h_clubmate <- hist(clubmate$timestamp, breaks='days', plot=FALSE)
h_floramate <- hist(floramate$timestamp, breaks='days', plot=FALSE)
h_clubcola <- hist(clubcola$timestamp, breaks='days', plot=FALSE)
h_eichbaum <- hist(eichbaum$timestamp, breaks='days', plot=FALSE)
h_karamalz <- hist(karamalz$timestamp, breaks='days', plot=FALSE)
img_dim <- 1000
xrange <- range(h_total$mids)
yrange <- range(h_total$counts)
show(xrange)
show(yrange)
jpeg("plot_total.jpg", width=img_dim, height=img_dim)
plot(h_total$mids, h_total$counts, col='black', xlab='Date', ylab='Sales/Day', main='Total', type='l')
dev.off()
jpeg("plot_clubmate.jpg", width=img_dim, height=img_dim)
plot(h_clubmate$mids, h_clubmate$counts, col='black', xlab='Date', ylab='Sales/Day', main='Clubmate', type='l')
dev.off()
jpeg("plot_floramate.jpg", width=img_dim, height=img_dim)
plot(h_floramate$mids, h_floramate$counts, col='black', xlab='Date', ylab='Sales/Day', main='Floramate', type='l')
dev.off()
jpeg("plot_eichbaum.jpg", width=img_dim, height=img_dim)
plot(h_eichbaum$mids, h_eichbaum$counts, col='black', xlab='Date', ylab='Sales/Day', main='Eichbaum *', type='l')
dev.off()
jpeg("plot_clubmate_cola.jpg", width=img_dim, height=img_dim)
plot(h_clubcola$mids, h_clubcola$counts, col='black', xlab='Date', ylab='Sales/Day', main='Clubmate Cola', type='l')
dev.off()
jpeg("plot_karamalz.jpg", width=img_dim, height=img_dim)
plot(h_karamalz$mids, h_karamalz$counts, col='black', xlab='Date', ylab='Sales/Day', main='Karamalz', type='l')
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment