Michael Robinson Assignment #2
for this assignment i will be inproting my data from a URL. the data is a .csv file called ProgramEffectiveness.csv
prog_eff <- read.csv("https://vincentarelbundock.github.io/Rdatasets/csv/AER/ProgramEffectiveness.csv", TRUE,",") #load .csv file from url
# in the following lines I will display an overview of the data and display the mean and median
summary(prog_eff) # Summary of data frame (prog_eff)
## X grade average testscore
## Min. : 1.00 Length:32 Min. :2.060 Min. :12.00
## 1st Qu.: 8.75 Class :character 1st Qu.:2.812 1st Qu.:19.75
## Median :16.50 Mode :character Median :3.065 Median :22.50
## Mean :16.50 Mean :3.117 Mean :21.94
## 3rd Qu.:24.25 3rd Qu.:3.515 3rd Qu.:25.00
## Max. :32.00 Max. :4.000 Max. :29.00
## participation
## Length:32
## Class :character
## Mode :character
##
##
##
mean(prog_eff$average) # find the mean of averages
## [1] 3.117188
median(prog_eff$average) # find the median of averages
## [1] 3.065
mean(prog_eff$testscore) # find the mean of test scores
## [1] 21.9375
median(prog_eff$testscore) # find the median of test scores
## [1] 22.5
# The following will display all the average less than 3.0
mystat <- prog_eff[prog_eff$average <= "3.0", ] # extract averages <= 3.0
mystat
# this following I will create a new subset using only 3 columns (grade, average, testsore)
my_subset <- prog_eff[ , c("grade", "average", "testscore")] # creating a subset
my_subset
# this following I will rename the columns (grade, average, testsore) to (group, standard, Trial_score) and display a summary of the subset
my_subset2 <- my_subset # creating a subset
colnames(my_subset2) <- c("Group ", "standard ", "trial_score") # renaming header in subset
my_subset2
summary(my_subset2) # Summary of new data frame
## Group standard trial_score
## Length:32 Min. :2.060 Min. :12.00
## Class :character 1st Qu.:2.812 1st Qu.:19.75
## Mode :character Median :3.065 Median :22.50
## Mean :3.117 Mean :21.94
## 3rd Qu.:3.515 3rd Qu.:25.00
## Max. :4.000 Max. :29.00
# in the following I will replace the values (20,22,17) with (30,31,19)
my_subset3 <- my_subset2
my_subset3[my_subset3 == 20] <- 30 # Changing values in data frame
my_subset3[my_subset3 == 22] <- 31 # Changing values in data frame
my_subset3[my_subset3 == 17] <- 19 # Changing values in data frame
my_subset3
my_subset3[1:10, ] # Display first 10 lines of subset
# The following code will read a csv file from my github.
githubfile <- 'https://raw.githubusercontent.com/MRobinson112/Assingment-2/main/ProgramEffectiveness.csv'
pgreff <- read.csv(githubfile)
head(pgreff, n = 10)
You can also embed plots, for example:
```
Note that the echo = FALSE
parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.