Little useless-useful R functions – Using xspline to create wacky signatures
This article is originally published at https://tomaztsql.wordpress.com
Nothing short of wacky usage of plot() function with xspline to interpolate the points, but still a “parameter” short of Bezier’s curve.
Given two random vectors, you can generate a plot that, xspline will smooth out the plot and give it a “signaturey” look.
The function itself is straightforward:
inscrp <- function(rep){
x <- rnorm(rep)
y <- rnorm(rep)
plot(x,y, pch = 1, col = "white", xaxt='n', yaxt='n', ann=FALSE, frame.plot=FALSE)
xspline(x,y, 1, draw = TRUE, col="blue")
}
but the results are splendid
Run the following:
par(mfrow = c(2,1))
inscrp(10)
inscrp(20)
par(mfrow = c(1,1))
And you will get either a signature kind of look or a doctor’s drug prescription. The main point is, both are impossible to read
Adding more points (e.g.: above 50) to inscrp() function might result in a Picasso drawing
As always, code is available on the Github in the same Useless_R_function repository. Check Github for future updates.
Happy R-coding and stay healthy!“
Thanks for visiting r-craft.org
This article is originally published at https://tomaztsql.wordpress.com
Please visit source website for post related comments.