0% found this document useful (0 votes)
17 views5 pages

Assignment 4 Bigdata

The document contains 4 questions and R code to solve them. Question 1 has code to compare two data frames and find elements that are not present. Question 2 has code to extract subsets of letters from a character vector. Question 3 has code to calculate the sum, mean, and product of a numeric vector. Question 4 has code to create and sort a data frame of employee details.

Uploaded by

gaurav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Assignment 4 Bigdata

The document contains 4 questions and R code to solve them. Question 1 has code to compare two data frames and find elements that are not present. Question 2 has code to extract subsets of letters from a character vector. Question 3 has code to calculate the sum, mean, and product of a numeric vector. Question 4 has code to create and sort a data frame of employee details.

Uploaded by

gaurav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy