I created my first shiny app. It creates some nice images with a few clicks.

I tried making a shiny app about 2 years ago, but I never really got it online for some reason. But after talking to a friend I tried again and it was surprisingly easy! Maybe I just got a lot better using R or the server infrastructure got a lot easier to use.

Anyway here you can play around with it.

I still could improve a few things UI-vice and maybe add more options. But honestly for a prove of concept it is good enough and I am quite happy how well it works. And I really like the results.

Trying to create Glitch Aesthetics with R and failing in a beautiful way

This newest project doesn’t have much to do with data visualization, besides I used R for it. I am into Glitch Art  since some time already. I usually used apps or some plugins to create my own. I was interested if I could write anything like this on my own. R is probably far from the  optimal tool to work on images, but it is the best “programming” language I know, so it must do. The blog Fronkostin did something with images in R recently and inspired me to try it too. He has actually a clue what he is doing with R and also knows some math, so he is worth checking out.

Here is my first try: I basically, selected a random square of the image and randomly shuffled to color channels around (RGB) or inverted them. And then I repeated the progress between 10 and 80 times. It is quite basic, but I love the look of it. And I just love that I can churn them out automatically, randomly creating an infinite amount of variants.  The whole thing is quite slow and is basically unusable with bigger images, probably have to look into it or start learning some Python.

I also wrote a little tool to create scanlines randomly, which basically involved creating a gap in the image and then filling it up with one line. I didn’t care too much about those result, so I just let them be. I will keep working on ideas, so I probably can bring it back with something else.





#convert image to dataframe. Add additional colorchannels, which will be changed.
mutate(red=red1, blue=blue1, green=green1)

 #this function randomly changes colorchannels of random squares. also uses negative of the colorchannel

colorswitches = function(data,negative=T){

#create cordinates for squares. choose randomly two points on the x and y axis. 

#there are 6 color variables. three of them are the originals. three of them are the ones who are changed
#variable which defines where color is picked from. chooses from orignal and changable variables. it is important that it also picks from original from time to time. because else at one point all becomes grey.
#randomly selects one of 3 changable variables

#add 1 to 6 chance the negative of the color is used.
minuscolor=ifelse (sample(1:6,1)==1,T,F)

#this is just that the for counter doesn't has to start at one. small speedup

for(i in startbla:nrow(data)){

#check if x and y is inside the defined square
if (data$y[i] > liney[1]){
if(data$x[i]<linex[2] & data$x[i]>linex[1]){

#two version of changing the color value of the selected channel. one negative on normal. 
if(minuscolor==T &negative==T) data[i,tocolor]=1-data[i,fromcolor]
else data[i,tocolor]=data[i,fromcolor]
#if y bigger then selected square, stop loop

#repeating the colorsquare function
for(i in 1:50){

#create proper RGB code from the three color channels
img=img%>% mutate(rgb=rgb(red,green,blue))

#display it with ggplot.
p<- ggplot(img,aes(x,y))+geom_raster(aes(fill=rgb))+scale_fill_identity()+

Women’s suffrage in Switzerland at the cantonal level

There are several reasons women in Switzerland gained the right to vote only in 1971. The main reason is the direct democracy. There had to be a referendum to give women the right to vote. It’s quite likely that many countries would have introduced the women suffrage later.

Continue reading “Women’s suffrage in Switzerland at the cantonal level”