Publications by tomaztsql

Little useless-useful R functions – Use pipe %>% in ggplot2

12.02.2021

Using pipe %>% or chaining commands is very intuitive for creating following set of commands for data preparation. Visualization library ggplot in this manner uses sign “+” (plus) to do all the chaining. What if we would have to replace with the pipe sign? So image your typical ggplot command: library(ggplot2) #sample DataSet iris <- iris g...

1047 sym R (644 sym/3 pcs) 4 img

Little useless-useful R functions – Using L-Systems for useless writing

17.02.2021

Writing useless strings has been a focus of this series, and L-Systems (Lindenmayer Systems) are no different. It is a set or a string of characters that is rewritten on each iteration, following a set of rules. Probably the most famous one is Fractal tree, Sierpinski triangle, Koch curve and many others. It can be represented as a iterative (rec...

1365 sym R (962 sym/4 pcs) 2 img

Little useless-useful R functions – Letter frequency in a vector of numbers

22.03.2021

So here is a useless fact. There is no letter A in numbers – written as words – from 1 to 100. And of course, we wanted to put this into the test and check if it holds the water. And sure, there is the result: Two sets of functions were created in this case (it can be stuffed in single one and super simplified, but it is all about uselessne...

2128 sym R (1660 sym/3 pcs) 10 img

Using SQL for R data.frames with sqldf

27.04.2021

There are many R packages for querying SQL Databases. Recently, I was looking into sqldf package | CRAN documentation. There are so many great advantages (simple running SQL statements, creating, loading, deleteing data to data.frames, connectivity to many databases, support for SQL functions, data types and many many more) , but one that was rea...

1667 sym R (230 sym/5 pcs)

Little useless-useful R functions – Looping through variable names and generating plots

24.05.2021

Facets in ggplot2 are great for showing multiple plots on a single canvas. Assuming this usually covers many scenarios, there might be a case that you would want to save all the combinations of x and y variables in a plot as a file. Useless scenario, and again somehow useful. Combination of Species and Petal.Width as boxplot Given a x-variable (i...

1377 sym R (357 sym/2 pcs) 2 img

Little useless-useful R functions – Inserting variable values into strings

09.07.2021

Another useless function that could be found in many programming languages. For example typical Python sample, that everyone have encountered would be: MyName = "Tomaz" Value_in_string = "My Name is {} and I write this post.".format(MyName) print(Value_in_string) Resulting in a string with: My Name is Tomaz and I write this post. So, let’s do...

928 sym R (624 sym/3 pcs) 2 img

Little useless-useful R functions – Is it raining yet?

12.07.2021

Summer. Sunny weather. Vitamin D. And if you are missing vitamin Rain because you are growing a garden or simply want an inner cooling, hit this useless function to see, if there is a rain anywhere to be seen. Source: Emoji u1f327 – Category:Rain icons – Wikimedia Commons Besides looking on the phone, on the web, or sticking the head out of t...

1783 sym R (538 sym/2 pcs) 4 img

Little useless-useful R functions – Colourful ggplot line graphs

16.07.2021

How about some colours in line graph? Or even more wacky? Nevertheless, let’s create a function that generates some sample “mocked” data and draws a line chart: #The function Colourful_graph <- function(n, x, y){ df <- data.frame(x=x, y=y, col=n) for (i in 1:n){ #get last x,y lastx <- tail(df$x, 1) lasty <- tail(df$y, 1) ...

991 sym R (1441 sym/3 pcs) 10 img

Little useless-useful R functions – Drawing calendar

19.07.2021

This time around, since first half of the 2021 is behind us, we are making Calendar in R. Simple outline of current month in calendar for 2021 This will be achieved with two useless functions. Function to draw a month (with optional parameter as current date) DrawCalendarMonth <- function(InDate=NULL) { if(is.null(InDate)){ date <- Sys.Dat...

1476 sym R (2382 sym/4 pcs) 6 img

Getting geo data into SQL Server using API and R

02.08.2021

R language (as well as Python) as comprehensive languages helping not only data analysis and data science tasks make it pretty easy, but is also a multiple-purpose language. In this blog-post I will examine ways of getting data into SQL SERVER using API. I have briefly discussed this already in one of my previous blog poss, but this time, we can ...

1772 sym R (3028 sym/2 pcs) 4 img