How to write the remaining data frame in R after randomly subseting the data
问题 I took a random sample from a data frame. But I don't know how to get the remaining data frame. df <- data.frame(x=rep(1:3,each=2),y=6:1,z=letters[1:6]) #select 3 random rows df[sample(nrow(df),3)] What I want is to get the remaining data frame with the other 3 rows. 回答1: sample sets a random seed each time you run it, thus if you want to reproduce its results you will either need to set.seed or save its results in a variable. Addressing your question, you simply need to add - before your