Nov 14, 2019 in R Language
Q: nth observation in R language

1 Answer

0 votes
Nov 14, 2019

The fonction nth() is complementary to first() and last(). You can access the nth observation within a group with the index to return.

For instance, you can filter only the second year that a team played.

# nth
data % > %
	group_by(teamID) % > %
	summarise(second_game = nth(yearID, 2)) % > %
	arrange(second_game)

Related questions

0 votes
Nov 14, 2019 in R Language
0 votes
Nov 14, 2019 in R Language
...