-1

enter image description here

I have a survey data as shown in this screenshot, some of the items are revised graded, therefore I need to replace the revised graded item's value: 1 to 5, 2 to 4 However, after changing 1 to 5, I cannot replace 5 to 1 because it will interfere with the variables that I just transformed. Does any know how to manage that? Thank you!

camille
  • 16,432
  • 18
  • 38
  • 60
Zixuan Ma
  • 21
  • 1
  • You can temporarily change 1 to 12, 2 to 23, 3 to 34, so on, and then change 12 to 2, 23 to 3, 34 to 4, and so on. The point is to make some temporary values for holding them in between, so values won't get mixed up later on. – Nuclear03020704 Dec 21 '19 at 04:40
  • 2
    [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question that folks can help with. That includes a sample of data (not a picture of it), all necessary code, and a clear explanation of what you're trying to do and what hasn't worked. We don't know how you're trying to approach this currently – camille Dec 21 '19 at 04:52
  • If your question is how to map {1, 2, 3, 4, 5} to {5, 4, 3, 2, 1}, then @BigFinger's answer has done it. If not, please provide reproducible data by `dput(head(D2))` and specify where you get stuck. – Darren Tsai Dec 21 '19 at 05:43

1 Answers1

2

Is this what you have in mind?

D2 = 6 - D2
BigFinger
  • 1,033
  • 6
  • 7