Format of R File
Format of R File
D. Create a data frame with 5 employees, their age, department, and monthly salary.
Program:
Output:
Program:
Output:
B. summary():
a) The summary() function provides a statistical summary of an object.
b) For numeric data, it includes minimum, maximum, mean, median, and quartiles.
c) For factors, it shows the count of each level.
d) For other data types, it provides relevant summaries
Program:
Output:
Program:
Output:
Project 5. Vector Operations
A. Create a vector of numbers from 1 to 200, divisible by 4. Perform:
a) Calculate the length.
b) Extract the 10th, 25th, and 50th elements.
c) Replace values at index 15 with NA and find the mean of the modified vector.
Program:
Output:
Program:
Output:
Program:
Output:
Program:
Output:
Program:
Output:
Project 10. Histogram Plotting
A. Generate a histogram for the distribution of ages in a dataset of 100 people.
Program:
Output:
Program:
Output:
Program:
Output:
Program:
Output:
Program:
Output:
Project 15. Generating a Matrix with Row-Major Order of Numbers in R
A. Create a matrix m of five rows in a row -major order of numbers from 1 to 100
incremented by a step of 5 units.
a) Find row and columns -wise means of matrix m.
b) Find the minimum value for each row and column.
c) Find the transpose and sort the values in each columns in decreasing order.
d) Assign the row names as R1to R5 and column names C1 to C4.
e) Display all the elements of the second and fourth column without using indices.
f) Display all the elements of the first and third row without using indices.
g) Create a new matrix by deleting the second and fourth column of matrix m using indices and
column names.
h) Replace elements at indices (2,3), (2,4), (3,3), and (3,4) with NA values.
i) Replace elements at index (1,3) with NaN.
j) Check if matrix m contains any NA or NaN values and interpret the output.
k) Create two new matrices rm and cm by concatenating matrix m row-wise and column-wise
with itself
Program:
Output:
Program:
Output: