This has been modified by LIU YANG for R Programming class