A user wants to know in what way he can randomly select a number of rows without replacement from a dataframe in R.

889    Asked by Sunitapandey in Data Science , Asked on Nov 10, 2019
Answered by Nitin Solanki

Let us create a dataframe

data = data.frame(matrix(rnorm(20), nrow=10))

Data


Now to randomly select 3 rows, we can do the following

data[sample(nrow(data), 3), ]




Your Answer

Interviews

Parent Categories