0% found this document useful (0 votes)
17 views

PROGRAMMING-EXERCISE-GROUP-8-2

Learn Programming Languages
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

PROGRAMMING-EXERCISE-GROUP-8-2

Learn Programming Languages
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

PROGRAMMING EXERCISE: DATA STRUCTURE

GROUP 8 — Daet, Lency May N., Gardoce, Allyssa Lou F., Omandac, Kashie Mae B.,
Paguio, Lebron James N., and Sarmiento, Reinier C.

I. 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


II. 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]

2.1 M GE: All male whose favorite subject is English

2.2 M GM: All male whose favorite subject is Math


2.3 M GS: All male whose favorite subject is Science

2.4 F GE: All female whose favorite subject is English


2.5 F GM: All female whose favorite subject is Math

2.6 F GS: All female whose favorite subject is Science


III. Create a vector of grade in math of all male students and name it GM_M.

IV. Extract the 20th to 40th observation of FAVORITE COLOR from the SAMPLE DATAV2
and save it to v1. Name v1 using the names () function with 20-40 that represents 20-40
observation. [2 points for correct code]
V. Create a list of factors of all categorical variables from the SAMPLE DATAV2. Name it
my list. If the categorical variable has ordinal level of measurement, make sure that the
factor is ordered.

VI. Create a vector containing the number of observations for each subset created from
item II. Retain the order. Save it in the variable freq . (Use nrow () function) [2 points for
correct code]
VII. Using the matrix function, create a table that shows the frequency of the students in
their favorite subject group according to gender. The row names should be the gender
(”MALE”, ”FEMALE”), and the column names should be the favorite subject (”ENGLISH”,
”MATH”, ”SCIENCE”). Name the matrix with my matrix. [3 points for correct code]

4.1 Extract the column for English and name it Eng. [1 point for correct code]
4.2 Extract the row for Male and name it m. [1 point for correct code]

VIII. 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: [2 points]

1. The data frame should include all students whose favorite color is either black, blue,
red, or yellow, and whose grades in the three subjects are above 85. [2 points]
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]

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]
4. Arrange the data in descending order based on their average grade in the three
subjects. [2 points]

5. Retain the following columns: [2 points]


● GENDER ● GRADE MATH
● AGE ● GRADE ENGLISH
● FAVORITE SUBJECT ● GRADE SCIENCE
● REL STATUS ● Ave
● STUDY HABIT ● Fave Math
6. Rename the columns as follows: [2 points]
● Gen for GENDE ● SH for STUDY HABIT
● A for AGE ● G_M for GRADE MATH
● FS for FAVORITE SUBJECT ● G_E for GRADE ENGLISH
● RS for REL STATUS ● G_S for GRADE SCIENCE

IX. 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. [4 points]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy