Assignment 4 Bigdata

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Q1) 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.

a<-data.frame(23,24,65,67)
b<-data.frame(23,65,45,79)
print(setdiff(a,b))
print(setdiff(b,a))

FINAL OUTPUT :
X24 X67
1 24 67
X45 X79
1 45 79
Q2) 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 in upper case.

print("First 10 letters in lower case:")


t = head(letters, 10)
print(t)
print("Last 10 letters in upper case:")
t = tail(LETTERS, 10)
print(t)
print("Letters between 22nd to 24th letters in upper case:")
e = tail(LETTERS[22:24])
print(e)

FINAL OUTPUT:
Q3) Write an R program to find sum,mean and product of
vector.

x = c(50, 60, 70)


print("Sum:")
print(sum(x))
print("Mean:")
print(mean(x))
print("Product:")
print(prod(x))

FINAL OUTPUT :

[1] "Sum:"
[1] 180
[1] "Mean:"
[1] 60
[1] "Product:"
[1] 210000
Q.4. Write an R program to create a dataframe which
contain details of employees and display the details in
ascending order.

emp= data.frame(Name=c("Rohit S","Sachin M","Neha


K","Ankita P","Dhruva D"),
age=c(28,29,30,26,25),
Gender=c("M","M","F","F","M"),
Designation=c("CEO","MD","Manager","SeniorOfficer","Sr.
Manager")
)
print(emp)
print(summary(emp))
as<-emp[with(emp,order(Name)), ]
print(as)

FINAL OUTPUT :

You might also like