Modifs on R function - Format input data