Q:

Change column values for certain counter values

I am reading in data with a loop like so : 
for(i in 1:2)
{
n= paste(i,".txt", sep="")
a<- sprintf("table%d", i, i)
data <- read.table(toString(n), header = TRUE, sep = "\t")
......

Then, I'm doing a bunch of stuff to data (getting trimmed means and such), then feeding into a master table which contains the mean values for each file. I'll do ANOVAs on the means later.
Anyway, I need to reverse the scores on certain files (those in the or statement) to make them equivalent ( a to b and b to a). This is how I've gone about it but it looks rather stupid, is there a neater syntax to do this?
if (i ==(2|4|6|7|9|11|14|16|18|19|21|23|25|28|30|32|34|36))
{
data$Reqresponse[data$Reqresponse == "a"] <- "nw"
data$Reqresponse[data$Reqresponse == "b"] <- "w"
data$Reqresponse[data$Reqresponse == "nw"] <- "b"
data$Reqresponse[data$Reqresponse == "w"] <- "a"
}

Thanks

A:

if you are trying to swap things out, you need to put them somewhere temporarily. 
If you do  a <- b and then b <- a  they will both end up with the same value. 
You need to instead do  TMP <- a a <- b b <- TMP 
As for the or statement, you are probably looking for %in% as @sebastian-c points out. 

