Which expression would be the most similar to the following one:
BDe(i,:) = [];
I use this to delete the row i of BDe (matrix n*m dimension) in a for loop.
A reproducible example:
data = [ 1 1 1 ; 2 2 2; 3 3 3]
data =
1 1 1
2 2 2
3 3 3
data(1,:)=[]
data =
2 2 2
3 3 3
Drop observations by iterating their matrix number row
Pretty sure you are looking for for
Example Data
data=read.table(text=" 1 1 1
2 2 2
3 3 3")
Code
data[-1,]
V1 V2 V3
2 2 2 2
3 3 3 3
Note please be aware of the following behavior in a loop.
x<-1:10
for(i in c(2,3,7)){x<-x[-i]}
x
[1] 1 3 5 6 7 8 10
It can be better to just do
x<-1:10
x[-c(2,3,7)]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments