written R codes to scripts