Você está na página 1de 2

DATA TABLE

library("data.table")

# Create your first data.table


my_first_data_table <- data.table(x = c("a","b","c","d","e"), y = c(1,2,3,4,5))

# Create a data.table using recycling


DT <- data.table(a = c(1L,2L), b = LETTERS[1:4])

# Print the third row to the console


DT[3]

# Print the second and third row to the console, but do not use any comma at
all
DT[2:3]

# The data.table DT is still loaded in your workspace

# Print the penultimate row of DT using `.N`


DT[.N-1]

# Print the column names of DT, and number of rows and number of columns
colnames(DT)
dim(DT)

# Select row 2 twice and row 3, returning a data.table with three rows where
row 2 is a duplicate of row 1.
DT[c(2,2,3)]

Você também pode gostar