Get startedGet started for free

Creating a data.table

Just like how the data.frame() function can be used to create a data frame, you can create a data.table using the data.table() function. In this exercise, you will create the following data.table:

X
   id value
1:  a   0.5
2:  b   1.0
3:  c   1.5

This exercise is part of the course

Data Manipulation with data.table in R

View Course

Exercise instructions

  • Load the data.table package.
  • Create the data.table X shown above. Note that the column id is of type character and value is of type numeric.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Load data.table
library(___)

# Create the data.table X 
X <- ___(___ = c("a", "b", "c"), ___ = c(0.5, 1.0, 1.5))

# View X
X
Edit and Run Code