Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Dec 21, 2024
1 parent b61e64c commit e4816b2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions man/setkey.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,6 @@ reference.
\examples{
# Type 'example(setkey)' to run these at the prompt and browse output
# Example: Single character vector of column names
DT = data.table(A = 5:1, B = letters[5:1], C = 10:6)
setindex(DT, A) # Set index using a single column
indices(DT) # View the indices
# Example: List of character vectors
setindexv(DT, list(c("A", "B"), c("B", "C"))) # Setting multiple indices
indices(DT) # View all indices
indices(DT, vectors = TRUE) # View indices as a list of vectors
DT = data.table(A=5:1,B=letters[5:1])
DT # before
setkey(DT,B) # re-orders table and marks it sorted.
Expand All @@ -152,6 +142,11 @@ setindex(DT, B)
indices(DT) # get indices single vector
indices(DT, vectors = TRUE) # get indices list

# Setting multiple indices at once
DT = data.table(A = 5:1, B = letters[5:1], C = 10:6)
setindexv(DT, list(c("A", "B"), c("B", "C")))
print(DT, show.indices=TRUE)

# Use the dot .(subset_value) syntax with integer keys:
DT = data.table(id = 2:1)
setkey(DT, id)
Expand Down

0 comments on commit e4816b2

Please sign in to comment.