Reputation: 6106
I have a matrix which consists of 13 columns (called PCs). I want to make a new matrix including only the rows that have a value between 4 and 8 (called EUR). I tried using this statement:
EUR <- PCs[which(PCs$V13 < 9 && PCs$V13 > 3), ]
Which unfortunately doesn't work... (I only get one row out, while there are hundreds)
Anyone knows what's wrong with this command?
Upvotes: 36
Views: 142697
Reputation: 42060
The &&
function is not vectorized. You need the &
function:
EUR <- PCs[which(PCs$V13 < 9 & PCs$V13 > 3), ]
Upvotes: 67