sample_n() function in R Language is used to take random sample specimens from a data frame.
Syntax: sample_n(x, n)
x: Data Frame
n: size/number of items to select
name age ht school 1 Chaman 9 NA no 2 Abhi 7 46 yes 3 Bhavesh 5 NA yes
 Chaman Bhavesh Dimri Levels: Abhi Bhavesh Chaman Dimri
Here, in the above code, column name is specified. Hence, the size is applied within the factor.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.