mardi 19 avril 2016

R: Automated ifelse calculation in matrix for every row

for a large matrix [n,1], I want to find out for every row, if a value is smaller 0.1 and if the following value (in the following row) is bigger 0.1.

ifelse(matrix[1,1]<0.1 & matrix[2,1]>0.1, "1", "0")

ifelse(matrix[2,1]<0.1 & matrix[3,1]>0.1, "1", "0")

ifelse(matrix[3,1]<0.1 & matrix[4,1]>0.1, "1", "0")`

How can I automate this calculation for every row?

Aucun commentaire:

Enregistrer un commentaire