Slip No 1.
Q. Write an R program to find the maximum and the minimum value of a given vector.
num = c(10, 20, 30, 40, 50, 60)
print(num)
print(paste("Maximum value of a given vector :",max(num)))
print(paste("Minimum value of a given vector :",min(num)))
Slip No 2.
Q.Write an R program to sort a Vector in ascending and descending order.
Answer :
x = c(10, 20, 30, 25, 9, 26)
print("Original Vectors:")
print(x)
print("Sort in ascending order:")
print(sort(x))
print("Sort in descending order:")
print(sort(x, decreasing=TRUE))
Slip No 3.
Q.1 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.
Answer :
a = c("a", "b", "c", "d", "e")
b = c("d", "e", "f", "g")
print("Original Dataframes")
print(a)
print(b)
print("Data in first dataframe that are not present in second dataframe:")
result = setdiff(a, b) print(result)

No comments:
Post a Comment