R for GDScript Developers
Move from GDScript to base R: vectors, missing values, data frames, functions, S3 dispatch, S4 validity and closure state. Build a connected multi-file basket and port a stock ledger.
GDScript and R side by side
The same program in GDScript and in R, from the lessons of this course.
Text and Output
GDScript print writes a line, often using str to convert values before concatenation. R cat requires an explicit final newline, while paste and paste0 construct strings. Rscript executes an entry file and source evaluates supporting declarations; there is no…
GDScript1extends SceneTree2 3func _init():4 var name = "Mira"5 # Preserve the space after the comma.6 print("Hello, " + name + "!")7 quit()R1ready <- 32cat(paste0("Ready: ", ready), "\n", sep="")Comparisons and Recycling
GDScript Arrays can compare by contents, while ordinary Object equality uses identity. R == is vectorized and may recycle shorter operands. Use all to reduce appropriate comparisons to one result or identical to include storage types and attributes. Missing…
GDScript1extends SceneTree2 3func _init():4 var a = [2, 3]5 var b = [2, 3]6 print(a == b)7 quit()R1cat(identical(1L, 1), all(c(2, 3) == c(2, 3)), "\n")Vector Subsetting
GDScript Arrays use zero-based positive indexes and support negative indexes from the end. R positive indexes start at one, negative indexes exclude positions and zero selects nothing. Translating -1 literally changes its meaning. Do not mix positive and…
GDScript1extends SceneTree2 3func _init():4 var values = [4, 8, 12]5 print(values[-1])6 quit()R1values <- c(4, 8, 12)2cat(paste(values[-1], collapse=" "), "\n", sep="")Typed Iteration
GDScript Array.map applies a Callable and returns an Array of results. R lapply returns a list, sapply attempts simplification and vapply checks each result against a type-and-length prototype. Choose the required result shape explicitly, especially for empty…
GDScript1extends SceneTree2 3func _init():4 var words = ["a", "tea"]5 var lengths = words.map(func(word): return word.length())6 print(str(lengths[0]) + ":" + str(lengths[1]))7 quit()R1words <- c("a", "tea")2sizes <- vapply(words, nchar, integer(1), USE.NAMES=FALSE)3cat(paste(sizes, collapse=" "), "\n", sep="")Functions and Returns
GDScript functions return values explicitly; reaching the end of an untyped function yields null. R returns the last evaluated expression by default and offers return for early exit. R functions use lexical scoping and lazy argument promises. Supporting files…
GDScript1extends SceneTree2 3func subtotal(price: int, quantity: int) -> int:4 price = price * quantity5 return price6 7func _init():8 var unit_price = 89 print(subtotal(unit_price, 3))10 print(unit_price)11 quit()R1is_long <- function(text) nchar(text)>42cat(is_long("coffee"), "\n", sep="")String Parsing
GDScript is_valid_int can check the full integer text before int conversion. R trimws and strsplit operate on character vectors, with strsplit returning a list of token vectors. Fixed separators and regular expressions have different meanings. Validate the…
GDScript1extends SceneTree2 3func _init():4 var text = "12cats"5 print("valid" if text.is_valid_int() else "invalid")6 quit()R1parts <- strsplit("tea,cake", ",", fixed=TRUE)[[1]]2cat(length(parts), "\n", sep="")
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFiles and Atomic Values
6 lessonsLogic and Iteration
6 lessonsCollections and Ownership
5 lessonsData and Transformations
4 lessonsFunctions and Closures
5 lessonsParsing and S3 Dispatch
5 lessonsObjects and Invariants
6 lessonsCollaboration and Contracts
5 lessonsProject: Basket
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is R for GDScript Developers for?
For people who already write GDScript and want to learn R. Each lesson starts from GDScript you know and shows how R does the same thing, so you skip the beginner basics.
Do I need to know R already?
No. The course starts with your first R program. You need GDScript basics: variables, conditions, loops, functions and collections.
How many lessons does R for GDScript Developers have?
R for GDScript Developers contains 48 interactive lessons you can complete at your own pace.
What does R for GDScript Developers cover?
The course is organized into chapters covering: Files and Atomic Values, Logic and Iteration, Collections and Ownership, Data and Transformations, and more.
Is R for GDScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.