Installing the Required Packages.

# install.packages("randomNames")

Neccessary packages for the task

library(randomNames)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.1.1     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

Generating 100 random names (first and last names) Using random names package

# for replication, set the seed to 2022
set.seed(2022)
# generate names
names <- randomNames(100); 
# look at the top 5 names
names[1:5]
## [1] "al-Asad, Nu'ma"   "al-Kazi, Zuhair"  "Finley, Lauren"   "Poghosyan, Randy"
## [5] "Ka, Gerald"

Generating the student’s grades using rnorm and floor functions.

The mean grade is 70 with a standard deviation of 15.

#set seed to 2020 for replication
set.seed(2022)
# generating the grades using rnorm and floor function
grades <- rnorm(100, mean = 70, sd = 15) %>%
  floor()
# look at top 5 grades
grades[1:5]
## [1] 83 52 56 48 65

put everything in a tibble with two columns, names and grades.

students.grade.df <- tibble(names, grades)
# head function of top 10 names
head(students.grade.df,10)
## # A tibble: 10 x 2
##    names                 grades
##    <chr>                  <dbl>
##  1 al-Asad, Nu'ma            83
##  2 al-Kazi, Zuhair           52
##  3 Finley, Lauren            56
##  4 Poghosyan, Randy          48
##  5 Ka, Gerald                65
##  6 Little, Kaitlyn           26
##  7 Rioja Piedras, Jacina     54
##  8 Gonzalez, Kahlin          74
##  9 al-Ismail, Sadeeda        81
## 10 Roach, Miranda            73

Exporting the dataframe to a csv file

write_csv(students.grade.df, "student_grades.csv")

The write_csv from readr package is approximately twice as fast compared to the write.csv base command. The outcome is also a clean csv file without row names included as a column.