0

how to use ifelse statement or other to solve like-this by one line code:

data[which(data > 2,arr.ind = T)] = 2.0  
data[which(data < -2,arr.ind = T)] = -2.0  

or

data2 = data
data2[which(data > 0,arr.ind = T)] = "A"  
data2[which(data <= 0,arr.ind = T)] = "B"
data = data2
ryster
  • 31
  • 4
  • Please provide a reproducible example and show what the desired output should look like. – Roman Luštrik Oct 13 '18 at 11:48
  • Hi @ryster, welcome to Stackoverflow. Please [follow these instruction](https://stackoverflow.com/a/5963610/9406040) to edit your question in a way that makes it possible for us to help you. – Roman Oct 13 '18 at 12:49

0 Answers0