Menu
CoddyTech
Course

R for TypeScript Developers

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

TypeScript and R side by side

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

  1. Text and Output

    TypeScript console.log writes a line, while Node process.stdout.write offers direct string output. R cat needs an explicit final newline; paste and paste0 construct strings. Rscript runs an entry file and source evaluates supporting declarations. R print may…

    TypeScript
    1const name="Ada";console.log("Hello, "+name);
    R
    1ready <- 32cat(paste0("Ready: ", ready), "\n", sep="")
  2. Comparisons and Recycling

    TypeScript structural compatibility does not create runtime structural equality: === still compares array and object identity. R == is elementwise and may recycle operands. Use all for a reduced decision or identical to include values, storage types and…

    TypeScript
    1const a=[2,3],b=[2,3];console.log(a===b);
    R
    1cat(identical(1L, 1), all(c(2, 3) == c(2, 3)), "\n")
  3. Vector Subsetting

    TypeScript Arrays have zero-based indexed elements; a negative bracket key is an ordinary property name rather than end-relative indexing. Array.at offers a separate negative-index convention. R positive indexes start at one and negative indexes exclude…

    TypeScript
    1const values=[4,8,12];console.log(values[values.length-1]);
    R
    1values <- c(4, 8, 12)2cat(paste(values[-1], collapse=" "), "\n", sep="")
  4. Typed Iteration

    TypeScript infers or checks Array.map callback result types, but the runtime operation still creates an ordinary array. R lapply returns a list, sapply attempts simplification and vapply checks a type-and-length prototype at runtime. Choose the required…

    TypeScript
    1const words: string[]=["a","tea"];const lengths: number[]=words.map(word=>word.length);console.log(lengths.join(":"));
    R
    1words <- c("a", "tea")2sizes <- vapply(words, nchar, integer(1), USE.NAMES=FALSE)3cat(paste(sizes, collapse=" "), "\n", sep="")
  5. Functions and Returns

    TypeScript result annotations check functions statically, but block bodies still need return to provide a value; expression-bodied arrows return their expression. R returns the last evaluated expression by default and uses lazy argument promises. Source…

    TypeScript
    1function twice(n:number):number{return n*2;}console.log(twice(3));
    R
    1is_long <- function(text) nchar(text)>42cat(is_long("coffee"), "\n", sep="")
  6. String Parsing

    TypeScript annotations do not make parseInt validate an entire string or prevent Number from returning NaN. R trimws and strsplit operate on character vectors, with strsplit returning a list of token vectors. Choose fixed or regex separators deliberately.…

    TypeScript
    1const text="12cats";console.log(Number.isNaN(Number(text))+":"+parseInt(text,10));
    R
    1parts <- strsplit("tea,cake", ",", fixed=TRUE)[[1]]2cat(length(parts), "\n", sep="")

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for TypeScript developers

Learn R from another language

Frequently asked questions

Who is R for TypeScript Developers for?

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

How many lessons does R for TypeScript Developers have?

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

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

Get started