The factor() function is incrementing my zeros to ones and ones to twos. Here's a simple example:
# Create some integers
ints <- as.integer(c(1,0,1))
ints
[1] 1 0 1
# Convert these to factors
f_ints <- factor(ints)
f_ints
[1] 1 0 1
Levels: 0 1
# Great! Let's just check one more thing...
str(f_ints)
Factor w/ 2 levels "0","1": 2 1 2
# Woah, whats up with those twos?
# Screw this, let's go back to integers
ints_again <- as.integer(f_ints)
ints_again
[1] 2 1 2
What accounts for this behavior? I thought this question and this question might explain this, but they're not the same.