Menu
CoddyTech
Course

R for Luau Developers

Move from Luau 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.

Luau and R side by side

The same program in Luau and in R, from the lessons of this course.

  1. Text and Output

    Luau print writes a line and can display several values; available input/output libraries depend on the host. Coddy supplies CLI I/O for these examples. R cat needs explicit separators and a final newline, while paste and paste0 build strings. R print may add…

    Luau
    1local name="Ada";print("Hello, "..name)
    R
    1ready <- 32cat(paste0("Ready: ", ready), "\n", sep="")
  2. Comparisons and Recycling

    Luau plain tables compare by identity unless an applicable equality metamethod changes the behavior. Static structural table types do not introduce runtime structural equality. R == is elementwise and can recycle operands. Use all for a reduced decision or…

    Luau
    1local a={2,3};local b={2,3};print(a==b)
    R
    1cat(identical(1L, 1), all(c(2, 3) == c(2, 3)), "\n")
  3. Vector Subsetting

    Luau dense sequences conventionally start at one, but table keys can also be zero or negative without special slicing meaning. R positive indexes are one-based, zero selects nothing and negative indexes exclude positions. A Luau negative key does not…

    Luau
    1local values={4,8,12};print(values[#values]);print(values[-1]==nil)
    R
    1values <- c(4, 8, 12)2cat(paste(values[-1], collapse=" "), "\n", sep="")
  4. Typed Iteration

    Luau mapping commonly loops over a sequence and writes a new table, optionally declaring its result element type. R lapply returns a list, sapply attempts simplification and vapply checks a type-and-length prototype for each callback result. Choose the output…

    Luau
    1local words={"a","tea"};local lengths={};for i,word in ipairs(words) do lengths[i]=#word end;print(table.concat(lengths,":"))
    R
    1words <- c("a", "tea")2sizes <- vapply(words, nchar, integer(1), USE.NAMES=FALSE)3cat(paste(sizes, collapse=" "), "\n", sep="")
  5. Functions and Returns

    Luau functions can annotate parameter and result types, but returning values still requires an explicit return. Runtime multiple-result adjustment differs from static type checking. R returns the last evaluated expression by default and evaluates ordinary…

    Luau
    1local function twice(value: number): number2    return value * 23end4print(twice(3))
    R
    1is_long <- function(text) nchar(text)>42cat(is_long("coffee"), "\n", sep="")
  6. String Parsing

    Luau tonumber returns nil when complete conversion fails, and its pattern syntax is not a general regular-expression syntax. R trimws and strsplit operate on character vectors, with strsplit returning a list of token vectors. Choose fixed separators or regex…

    Luau
    1print(tonumber("12cats")==nil and "invalid" or "valid")
    R
    1parts <- strsplit("tea,cake", ",", fixed=TRUE)[[1]]2cat(length(parts), "\n", sep="")

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for Luau developers

Learn R from another language

Frequently asked questions

Who is R for Luau Developers for?

For people who already write Luau and want to learn R. Each lesson starts from Luau 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 Luau basics: variables, conditions, loops, functions and collections.

How many lessons does R for Luau Developers have?

R for Luau Developers contains 48 interactive lessons you can complete at your own pace.

What does R for Luau 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 Luau Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start R for Luau Developers for free

Get started