Skip to content

Commit

Permalink
PROJECT_LANG_1.r
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpm2001 committed Aug 3, 2023
1 parent 27378c5 commit 8c8f726
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions PROJECT_LANG_1.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env Rscript
# Project language file 1
# For: AI2001/Categories/Linguistics/Fula

Check warning on line 3 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=3,col=3,[commented_code_linter] Commented code should be removed.
# About
# I decided to make R the 1st and main project language file for this project (AI2001/Categories/Linguistics/Fula) as R is the perfect language to use for data mining and related Artificial Intelligence work, but will be backed up with Python, among other languages. For data sets, R will be the main language, and RMarkdown will be a supporting language. It is getting its own project language file, starting here.

Check warning on line 5 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=5,col=81,[line_length_linter] Lines should not be more than 80 characters.

# Now time for a Mandelbrot (From Wikipedia/wiki/R/)

install.packages("caTools") # install external package
library(caTools) # external package providing write.gif function
jet.colors <- colorRampPalette(c("red", "blue", "#007FFF", "cyan", "#7FFF7F",

Check warning on line 11 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=11,col=1,[object_name_linter] Variable and function name style should be snake_case or symbols.
"yellow", "#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),

Check warning on line 15 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=15,col=1,[object_name_linter] Variable and function name style should be snake_case or symbols.
imag = rep(seq(-1.2, 1.2, length.out = dy), dx))
C <- matrix(C, dy, dx) # reshape as square matrix of complex numbers

Check warning on line 17 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=17,col=1,[object_name_linter] Variable and function name style should be snake_case or symbols.
Z <- 0 # initialize Z to zero

Check warning on line 18 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=18,col=1,[object_name_linter] Variable and function name style should be snake_case or symbols.
X <- array(0, c(dy, dx, 20)) # initialize output 3D array

Check warning on line 19 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=19,col=1,[object_name_linter] Variable and function name style should be snake_case or symbols.
for (k in 1:20) { # loop with 20 iterations
Z <- Z^2 + C # the central difference equation

Check warning on line 21 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=21,col=3,[object_name_linter] Variable and function name style should be snake_case or symbols.
X[, , k] <- exp(-abs(Z)) # capture results

Check warning on line 22 in PROJECT_LANG_1.r

View workflow job for this annotation

GitHub Actions / run-lint

file=/github/workspace/PROJECT_LANG_1.r,line=22,col=3,[object_name_linter] Variable and function name style should be snake_case or symbols.
}
write.gif(X, "Mandelbrot.gif", col = jet.colors, delay = 100)

# File info

# File type: R Source file (*.r *.rdata *.rds *.rda)
# File version: 1 (2023, Wednesday, August 2nd at 7:57 pm PST)
# Line count (including blank lines and compiler line): 33

# End of script

0 comments on commit 8c8f726

Please sign in to comment.