Use R format function instead of sprintf