Writing Validate.R in python