ST 104-Rstudio Exercise03
ST 104-Rstudio Exercise03
Exercise03
description
Team of the each player. There are 14 teams
Name of the each player
Salary of the each player per year in US
Dollars
Position of the each player.
a)
I.
II.
III.
IV.
V.
VI.
VII.
VIII.
IX.
b)
I.
Code the data as follows then add the new column to the data frame. Hint: use a for
loop.
Original value
Salary 0-500000 $
Salary above 500000$
II.
III.
IV.
V.
Coded value
0
1
Hence draw a stack bar chart for the position and the code variable.
Sort the data set based on the salary.
Count the number of players which are from the Boston Red Sox team using a loop.
Count the number of players from other than New York Yankees.
ST 104- RSTUDIO
Exercise03
2)
I.
II.
III.
Write a function to obtain the trace of a 2x2 matrix. The trace of a matrix is the sum of
the diagonal elements of that matrix.
Hence calculate the trace of the following matrix.
2 3
[
]
4 5
Write a R function to calculate the factorial values.