in R Language by
Q:
nth observation in R language

▼ Show 1 Answer

0 votes
by

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)
Learn More with Madanswer

Related questions

0 votes
asked Nov 14, 2019 in R Language by MBarbieri
...