R programming assignment modified