fixed code bugs. R doesn't like python syntax.