Search
 
SCRIPT & CODE EXAMPLE
 

R

R caTools library with Mandelbrot set

install.packages("caTools")  # install external package
library(caTools)             # external package providing write.gif function
jet.colors <- colorRampPalette(c("green", "pink", "#007FFF", "cyan", "#7FFF7F",
                                 "white", "#FF7F00", "red", "#7F0000"))
dx <- 1500                    # define width
dy <- 1400                    # define height
C  <- complex(real = rep(seq(-2.2, 1.0, length.out = dx), each = dy),
              imag = rep(seq(-1.2, 1.2, length.out = dy), dx))
C <- matrix(C, dy, dx)       # reshape as square matrix of complex numbers
Z <- 0                       # initialize Z to zero
X <- array(0, c(dy, dx, 20)) # initialize output 3D array
for (k in 1:20) {            # loop with 20 iterations
  Z <- Z^2 + C               # the central difference equation
  X[, , k] <- exp(-abs(Z))   # capture results
}
write.gif(X, "Mandelbrot.gif", col = jet.colors, delay = 100)
Comment

PREVIOUS NEXT
Code Example
R :: r for data science 
R :: select number of row dataframe r 
R :: how to remove all attributes from a variables in r 
R :: how to change column names in r 
Rust :: rust take user input 
Rust :: rust random number in range 
Rust :: array as a parameter rust 
Rust :: how to split a string by spaces rust 
Rust :: for loops in rust 
Rust :: rust comment 
Rust :: rust string from bytes 
Rust :: rust square root 
Rust :: rust trait 
Rust :: armanriazi•rust•pattern•design•interior•mutability•refcell 
Rust :: Project Euler #1 Multiples of 3 or 5 
Rust :: rust lang underscore 
Rust :: armanriazi•rust•concept•dynamic•dispatch 
Rust :: how to create an integer in rust 
Rust :: armanriazi•rust•error•[E0782]: trait objects must include the `dyn` keyword 
Rust :: bevy disable plugin 
Rust :: armanriazi•rust•trait•blanket 
Rust :: armanriazi•rust•trait•where 
Lua :: lua loop through table 
Lua :: roblox what is the difference between __index and __newindex 
Lua :: lua float to int 
Lua :: lua gsub 
Lua :: roblox number generator 
Lua :: function return lua 
Lua :: free roblux 
Lua :: Print when a player joined roblxo 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =