I know head() and tail() function will return the first or last parts of a dataset, but I wanna know if the two functions are gonna order the output, or just return without ordering them? Thanks many in advance!
Asked
Active
Viewed 253 times
1 Answers
1
As you can see below, they do keep the original order:
df <- data.frame(number = 1:26, letter = letters[1:26])
> head(df)
number letter
1 1 a
2 2 b
3 3 c
4 4 d
5 5 e
6 6 f
> tail(df)
number letter
21 21 u
22 22 v
23 23 w
24 24 x
25 25 y
26 26 z

broti
- 1,338
- 8
- 29
-
OK. I use this method and have a try. The two functions won't change the order. But actually I think your examples here are not so reasonable cuz df here is an orderly data frame itself. Thank you so much! – Chris Mar 26 '20 at 15:37