August 2019

recursive shape fractal generator

August 19, 2019 | exploRations in R

Intro This function allows us to generate the Sierpinski Triangle and explore other recursive shapes with equal length sides following the same algorithm.
shape <- function(corners, trials = 100000){
    
    corners <- as.integer(corners)
    points <- list()

    if (corners < 3) stop("Value should be 3 or greater")
 
    for (n in 1:(corners)){
     points$x[n] <- 0 + cos((2*pi*n)/corners)
        points$y[n] <- 0 + sin((2*pi*n)/corners)
    }

    x <- points$x[1]
    y <- points$y[1]

    trials <- trials
    sierpinski <- list()

    for (t in 1:trials){
        r <- sample(1:corners,1)
        x <- (x + points$x[r]) / sqrt(corners + 1)
        y <- (y + points$y[r]) / sqrt(corners + 1)
        sierpinski$x[t] <- x
        sierpinski$y[t] <- y
    }

 
    # I use these colors for random color selection. Update for your own desired selection.
    color <- sample(c("royalblue2", "firebrick2", "gold2", "springgreen3", "purple2", "darkorange1"),1)

    plot(sierpinski$x[corners:trials], sierpinski$y[corners:trials],
        xlab = paste0(corners, " Sides Chosen"), ylab = "", xaxt = "n", yaxt = "n", col = color)

}
When you run the function, you indicate the number of sides for the polygon and adjust the number of trials to change the resolution if desired. ...
[Read more...]

Correspondence Analysis visualization using ggplot

August 19, 2019 | Rcrastinate

What we want to do Recently, I used a correspondence analysis from the ca package in a paper. All of the figures in the paper were done with ggplot. So, I wanted the visualization for the correspondence analysis to match the style of the other figures. The standard plot method ...
[Read more...]

Regular Sequences

August 19, 2019 | Han de Vries

So far in this series, we used vectors from built-in datasets (rivers, women and nhtemp), or created them by stringing together several numbers with the c function (e.g. c(1, 2, 3, 4)). R offers an extremely useful shortcut to create vectors of the latter kind, which is the colon : operator. Instead of ...
[Read more...]

No visible binding for global variable

August 18, 2019 | Random R Ramblings

Recently I have been working on a very large legacy project which utilises the excellent data.table package throughout. What this has resulted in is an R CMD check containing literally thousands of NOTEs similar to the following:
❯ checking R code for possible problems ... NOTE
  my_fn: no visible binding for global variable ‘mpg’
There are several reasons why you might see these NOTEs and, ... [Read more...]

Mueller Report Volume 1: Network Analysis

August 18, 2019 | sam

settle down and have another cup of coffee code TLDR There are a lot of Russian’s talking to a lot of Trump campaign members in Mueller report. There are so many it’s tough to get your head around it all. In this post I attempted some network analysis ...
[Read more...]

Dash with golem: The beginning

August 18, 2019 | Sébastien Rochette

{golem} has been developed to help building big Shiny application to put in production. What if {golem} could be used to build another popular interactive web application, recently made available to R programmers: Dash ? Dash, a newcomer in interactive... [Read more...]

noaastorms R package now supports NOAA IBTrACS v4

August 17, 2019 | Blog - BS

Earlier this year, I released a simple R package (available at basilesimon/noaastorms) that downloads, cleans and parses NOAA IBtrack data for you. As the NOAA updated its datasets, noaastorms is now using these! How to install library(devtools) install_github("basilesimon/noaastorms") Available functions getStorms: Fetch NOAA historical best ...
[Read more...]

Tech Dividends, Part 2

August 16, 2019 | R Views

In a previous post, we explored the dividend history of stocks included in the SP500, and we followed that with exploring the dividend history of some NASDAQ tickers. Today’s post is a short continuation of that tech dividend theme, with the aim of demonstrating how we can take our ...
[Read more...]
1 4 5 6 7 8 14

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)