1
For example, the column in my Data Frame has values from 1 to 7; I want to replace 1 by 7, 2 by 6, 3 by 5, and so on. How to do this in R?
variable = 1,2,2,4,3,6,7 desired result = 7,6,6,4,5,2,1
1
For example, the column in my Data Frame has values from 1 to 7; I want to replace 1 by 7, 2 by 6, 3 by 5, and so on. How to do this in R?
variable = 1,2,2,4,3,6,7 desired result = 7,6,6,4,5,2,1
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
You can use the function
rev()
c<-data.frame((rev(x)),y)
– Magliari
That’s not
8 - x
, wherex
is the vector to modify?– Rui Barradas
x <- c(1,2,2,4,3,6,7);y <- c(7,6,6,4,5,2,1);identical(y, 8 - x)
.– Rui Barradas
I collected data together with a group of respondents, the question was how interested you are in the TV show x. Respondents had to indicate their interest on a 7-point scale. In my data.frame there is a column whose title is "interest" which contains the responses of 1 to 7 out of 73 respondents. I want to know how to invert these values from the data.frame column, ie where there is 1 the value will be changed to 7, where there are 2 will be changed to 6, where there is 3 the value will be changed to 5, and so on.
– Daniel Max