Difficulty: beginner
Estimated Time: 10 minutes

The journey of R language starts with the types it provides.

Welcome to the R types Katacoda scenario!

You've completed R Types scenario.

You've learnt about:

  • basic types
  • vectors & lists
  • accessing elements
  • matrices
  • data frames

Find out how to convert between types in the next scenario of the course.

Types in R

Step 1 of 8

Basic Types

Like many other languages, R has a variety of basic types and more complex types that can be created from the 'atomic' ones. Basic types in R are:

  • numeric (real)
  • integer
  • character
  • logical
  • complex

Creating a variable of a specific type can be done by using assign <- operator:

num <- 10

For initialising text variable you can use both ' and ":

chr <- "some text"

Logical values can be created using TRUE/FALSE or just T/F:

log <- TRUE

Notice that R is dynamic when it comes to types, so you can assign character value to the variable that previously was set to different type:

myVar <- 10

myVar <- 'text value'