Dear PDXRugger,
If I understand correctly, try this:
# Data
x = c(1:5,1,4,7)
# Option 1
require(car)
y1=recode(x, "1=4; 4=2; 7=3")
# Option 2
y2=ifelse(x==1,4,
ifelse(x==4,2,
ifelse(x==7,3,x)))
# Are y1 and y2 equals?
all.equal(y1,y2)
# Ordering x by y1
x[order(y1)]
See ?order, ?ifelse and ?r
See
?is.element
?order
and perhaps
?ave
and
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
as it says on your own email!
What you provide is not reproducible.
HTH,
I have consulted the intro and nabble but have not found an answer to what
should be a simple question, here goes:
I am doing a crosscheck of a data frame and pulling out a single value based
on an inputted value ie based on x i will select y, or if x =2 then my code
returns 7.
xy
1 4
2
3 matches
Mail list logo