Things-to-Note: - 1) Don’t rename external files or edit them in any way 2) Don’t change the variable names 3) Don’t destroy or overwrite any variables 4) Don’t use global path in your script. Instead use “setwd()” interactively in the console, but don’t include this code in your submission
If you don’t take above instructions into account it might effect your grades.
Your Information: Fill in the empty quotations with the correct information!
firstname <- "Ryan" # example:firstname <- "Liam"
lastname <- "Bencomo" # example: lastname <-"Mueller"
username <- "rybencomo" #example: username <- "lomueller" Do not include the "@ucsd.edu" part!
Remember to add author in line 3 and date in line 4, example: date: “10/8/2025”
If you forget to add your name, then you might not receive any points for this assignment ***
This week, your assignment is to begin manipulating data in R. You will also learn how to import data from .CSV files. Each week during these section times, you will work in pairs or small groups to complete the tasks.
Section 1: Answer the following questions by typing the appropriate code in the code boxes (denoted by ``` signs). In all boxes when necessary, I have included the name of the object you need to create and the code to display that object. Please leave that code intact for this week. It helps speed up the grading process. Be mindful of code chunks that you are not to modify at the end of each question.
Questions:
X<- c(1,3,5,6,7,9)
X
## [1] 1 3 5 6 7 9
Y<- c(2,7,4,5,2,12)
Y
## [1] 2 7 4 5 2 12
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q1 <- X
q2 <- Y
Z <- c(X,Y)
Z
## [1] 1 3 5 6 7 9 2 7 4 5 2 12
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q3 <- Z
meanZ<- Z/12
meanZ
## [1] 0.08333333 0.25000000 0.41666667 0.50000000 0.58333333 0.75000000
## [7] 0.16666667 0.58333333 0.33333333 0.41666667 0.16666667 1.00000000
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q4 <- meanZ
newZ<- Z[Z<7]
newZ
## [1] 1 3 5 6 2 4 5 2
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q5 <- newZ
lengthX<- length(newZ)
lengthX
## [1] 8
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q6 <- lengthX
DataWeek2<-read.csv("Child_Heart_Surgery.csv")
head(DataWeek2)
## Hospital Operations Survivors Deaths
## 1 London - Harley Street 418 413 5
## 2 Leicester 607 593 14
## 3 Newcastle 668 653 15
## 4 Glasgow 760 733 27
## 5 Southampton 829 815 14
## 6 Bristol 835 821 14
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q7 <- DataWeek2
survivors_vector <- c(DataWeek2$Survivors)
total_vector <- c(DataWeek2$Operations)
SurvivalRate <- survivors_vector / total_vector * 100
print(SurvivalRate)
## [1] 98.80383 97.69357 97.75449 96.44737 98.31122 98.32335 97.66022 97.88054
## [9] 98.26325 98.23322 97.13115 97.52917 98.99577
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q8 <- SurvivalRate
8.Add the information you calculated in question 7 as a new column to the right of your data table.
DataWeek2new <- SurvivalRate
head(DataWeek2new)
## [1] 98.80383 97.69357 97.75449 96.44737 98.31122 98.32335
### This chunk of code is for grading purposes.
### Don't change/delete this chunk of code.
q9 <- DataWeek2new
Double check that your name and date are correct, then check your work. Finally click the Knit button above(It looks like a blue ball of yarn). Save the file with your name and the week number in the file name
(for example: “DONE_BILD5_week2_Liam_Mueller.rmd”).
Then Upload the rmd file to Canvas under Week 2 Section Assignment before the deadline.