Big Data Lab R Code with output.docx
Big Data Lab R Code with output.docx
Q.1 Write an R program to find the maximum and the minimum value of a given vector.
R Code:
# Define the vector my_vector <- c(12, 45, 3, 67, 23, 89, 1)
# Calculate the maximum value max_value <- max(my_vector)
# Calculate the minimum value min_value <- min(my_vector)
# Print the maximum value
cat("The maximum value is:", max_value, "\n")
# Print the minimum value
cat("The minimum value is:", min_value, "\n")
OUTPUT:
Q.3 Write an R program to compare two data frames to find the elements in first data frame that
are not present in second data frame.# Create two sample data frames
R Code:
OUTPUT:
ASSIGNMENT 2
Q.1 Write an R program to extract first 10 English letter in lower case and last 10 letters in
upper case and extract letters between 22nd to 24th letters in upper case.
R Code:
OUTPUT:
Q.2 Write an R program to find Sum, Mean and Product of a Vector.
R Code:
Q.3 Write an R program to create a simple bar plot of five subject’s marks.
R Code:
OUTPUT:
ASSIGNMENT 3
Q.1 Write an R program to create a Dataframes which contain details of 5 employees and display
the details in ascending order.
R Code:
OUTPUT:
Q.2 Write an R program to create a data frame using two given vectors and display the
duplicated elements and unique rows of the said data frame.
R Code:
# Define the two vectors
vector1 <- c(1, 2, 2, 3, 4, 4, 5)
vector2 <- c('A', 'B', 'B', 'C', 'D', 'D', 'E')
OUTPUT:
Q.3 Write an R program to change the first level of a factor with another level of a given factor.
R Code:
# Define a factor
original_factor <- factor(c("low", "medium", "high", "medium", "low", "high"))
OUTPUT:
ASSIGNMENT 4
Q.1 Write a script in R to create a list of cities and perform the following
1. Give names to the elements in the list.
2. Add an element at the end of the list.
3. Remove the last element.
4. Update the 3rd Element
R Code:
OUTPUT:
Q.2 Write a script in R to create two vectors of different lengths and give these vectors as input to
array and print addition and subtraction of those matrices.
R Code:
OUTPUT:
Q.3 Write an R Program to calculate Multiplication Table
R Code: