I’m new in R so my question is probably trivial. I would like to make a matrix x1i of 50 random vectors (from matrix x) with condition [,27]==0. For example: in my x matrix I have 70 vectors where [,27]==0 and I would like to randomly select 50 of them.
x<-matrixData #100 rows and 27 columns
xi<-x[x[,27]==0,]
x1i<-xi[sample(1:50),]
Is that ok? Now I would just like to create another matrix x2 from the remaining (50) vectors/rows that were not in x1i. So simply x minus x1i. Everything I try, I get
Error in xj[i] : invalid subscript type 'list'
Any help is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire