finished the first conversion
from r to python