drop

Syntax

drop(obj, count)

Details

Drops a specified number of elements, columns or rows from the front or end of a vector, matrix or table.

Parameters

obj is a vector/matrix/table.

count is an integer specifying the number of elements/columns/rows to drop. If negative, drop from the end of obj.

Returns

An object with the same data type and form as obj.

Examples

x=1..10;
x.drop(2);
// output: [3,4,5,6,7,8,9,10]
x.drop(-2);
// output: [1,2,3,4,5,6,7,8]

x=1..10$2:5;
x;
#0 #1 #2 #3 #4
1 3 5 7 9
2 4 6 8 10
drop(x,2);
#0 #1 #2
5 7 9
6 8 10
x drop -2;
#0 #1 #2
1 3 5
2 4 6
t=table(1 2 3 4 as x, 11..14 as y);
t;
x y
1 11
2 12
3 13
4 14
t.drop(2);
x y
3 13
4 14

Related functions: pop!, removeHead!, removeTail!, remove!