ple[i, 5] == "B") {
samplemod[i,j] <- switch(sample[i,j], AA = 0,
AB = 1, BA = 1, BB = 2)
}
}
}
}
}
--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4
Yes here it is. I actually convert them all as strings, initially using
options(stringsAsFactors=F) at the top of my code.
This what the initial dataframe looks like. Please note this is a toy
dataset:
namesXYZAorB
S1BBBBBBA
S2AABBBBA
S3AB
Hello,
Your data.frame is composed exclusively of factors, but try this
(I've changed the name to 'sampl', because 'sample' is an R function.)
# logical index vectors
iA <- sampl$AorB == "A"
iB <- sampl$AorB == "B"
new.sampl <- data.frame(
apply(sampl, 2, function(x){
i
Can you show us what you want the final data.frame to look like? You've
created five variables stored as factors and you seem to be trying to change
those to numeric values? Is that correct?
Since AB and BA are always set to 1, you could just replace those values
globally rather than mess with th
4 matches
Mail list logo