I am having trouble with a loop I am creating. My intention is that the loop will see where a value falls and give that value another name. Here is an example of what I am trying to do:
a<-rnorm(10,0,1)
b<-rnorm(10,0,1)
testing<-data.frame(a,b)
testing2<-testing
for (i in 1:nrow(testing2)){
for (j in 1:ncol(testing2)){
if (testing2[i,j]>1) testing2[i,j]<-"More"
else if (testing2[i,j]<(-1)) testing2[i,j]<-"Less"
else testing2[i,j]<-"Same"
}
}
When I look at testing2 and compare it to testing, it does not match what it should be doing. "More" seems to work, but it gets mixed up between "Less" and "Same".