0% found this document useful (0 votes)
36 views17 pages

Eda - Quiz No.2

The document discusses analyzing engineering data. It includes creating vectors and matrices from sample data, subsetting data frames based on conditions, and manipulating data frames using dplyr. Several tasks involve creating variables to hold vectors and data frames from sample data and performing operations like averaging grades and subsetting based on favorite subjects and colors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views17 pages

Eda - Quiz No.2

The document discusses analyzing engineering data. It includes creating vectors and matrices from sample data, subsetting data frames based on conditions, and manipulating data frames using dplyr. Several tasks involve creating variables to hold vectors and data frames from sample data and performing operations like averaging grades and subsetting based on favorite subjects and colors.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Francisco, Gieselle Margarette BSCE 2-5

Gerona, Everett Gail


Pequit, Jeraldine
Viray, Darlene Nichole

ENGINEERING DATA ANALYSIS


Quiz No. 2

PROGRAMMING EXERCISES: DATA STRUCTURES

1. The data below represent the results of 70 individuals who took the depression test instrument.

1.1 Create a vector containing all the test scores and save it in a variable named score. [2 points]

1.2 Name the elements of the score vector with integer values from 1 to 20. [2 points]

2. Twenty individuals were given a list of 20 words to process. Half of them underwent shallow processing,
and the other half underwent deep processing. The table below shows the number of words correctly
recalled by the individuals.

2.1 Create a vector for each processing type, then save the vectors in variables shallow and deep
respectively. [4 points]
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

2.2 Create a factor that contains 10 ”shallow” and 10 ”deep”. [2 points]

3. The table below reflects the number of individuals classified according to their body mass index and their
social well-being.

3.1 Create a matrix in R for this table and save it in a variable named that removes the frequencies under
the underweight rows (Use the function in extracting a matrix). [2 points]
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

4. From the SAMPLE_DATAV2 data frame, create a new data frame and name it FSvsGRADE_DF. This data
frame should include the variables below, with the
new variable name on their left:

G: GENDER
FS: FAVORITE SUBJECT
GE: GRADE ENGLISH
GM: GRADE MATH
GS: GRADE SCIENCE
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

5. Create a subset out of the FSvsGRADE_DF data frame with the conditions below. Save these subsets on
the respective variable given on their left. [2 points each correct code]

5.1 Fave_Math: All students whose favorite subject is Math.


Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

5.2 Fave_notMath: All students whose favorite subject is not Math.


Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

5.3 M_Science: All male whose favorite subject is Science

5.4 M_notScience: All male whose favorite subject is not Science


Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

6. Use the data frames from item 5 to create the following vectors and save them in their respective variable
names on the left. [2 points each correct code]

6.1 GMath_FaveMath: Grade in math of all students whose favorite subject is Math.
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

6.2 GMath_FavenotMath: Grade in english of all students whose favorite subject is


not Math.
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

6.3 GScie_FaveScie: Grade in Science of all male students whose favorite subject is
Science.
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

7. Using the dplyr package, manipulate SAMPLE DATAV2 to create a data frame with the following conditions and
save it in a variable ’NEWDATA’. Manipulate SAMPLE_DATAV2 in the following order:
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

7.1 The data frame should include all students whose favorite color is either blue,
red, or yellow, and whose grades in the three subjects are above 85. [2 points]
7.2 Add a column with the column name ’Ave.’ This column should contain the
average of the three subjects: Grade in Math, Grade in English, and Grade in
Science. [2 points]
7.3 Add a column with the column name ’Fave Math.’ This column should contain
’T’ if the favorite subject is ’MATH,’ otherwise ’F.’ [2 points]
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole
Francisco, Gieselle Margarette BSCE 2-5
Gerona, Everett Gail
Pequit, Jeraldine
Viray, Darlene Nichole

8. From NEWDATA data frame in item VIII, compute the mean and the standard deviation of the average of the three
subjects (in ’Ave’ column) for each favorite subject. [2 points]

You might also like