Question
(Data science and visualisation) Write the following syntax in one script using comments to indicate the question number and turn in your script to the
(Data science and visualisation)
Write the following syntax in one script using comments to indicate the question number and turn in your script to the drop box.
- Define two vectors, a and b, where a=(3, 15, 22, 17) and b=(2, 3). Conduct the following operations and report what you observe as a result:
- a*b
- ab
- a+b
- In a social survey, there is one variable marital status with 4 elements: single, married, divorced, and widow
- Create a character vector named marital_status with the above 4 elements
- Convert the character vector in a) to a factor
- Convert the factor in b) to a numeric vector
- a) Create a matrix B
3 4 5 7
-2 6 8 10
12 -3 7 6
b) Show the second column of the matrix
c) Show the element on the first row second column
- a) Create a data frame
ID | Gender | Age | Diastolic blood pressure | Systolic Blood Pressure | Temperature |
A | Male | 55 | 90 | 130 | 98.5 |
B | Female | 42 | 80 | 111 | 99.0 |
C | Male | 39 | 79 | 115 | 98.7 |
b) Add a row where ID=D, Gender=Female, Age=60, DBP=101, SBP=135, Temperature=98.3
c) Add a column named as weight with the values of (155, 121, 147, 112) to the data frame with that row in b) added
d) Find the mean temperature of all four individuals
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started