0% found this document useful (0 votes)
2 views

Programming Questions

The document outlines a series of programming exercises for the subject 'Foundations of Data Science' with a focus on R programming. Each exercise covers various tasks such as creating vectors, performing calculations, and generating visualizations. The exercises are designed to enhance understanding of data manipulation and analysis using R.

Uploaded by

pradeepzyva
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming Questions

The document outlines a series of programming exercises for the subject 'Foundations of Data Science' with a focus on R programming. Each exercise covers various tasks such as creating vectors, performing calculations, and generating visualizations. The exercises are designed to enhance understanding of data manipulation and analysis using R.

Uploaded by

pradeepzyva
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name of the Subject : Foundations of Data Science

Code:222MDS1303
Programming Exercises
Each Question carries 5 marks

1. Write R commands for vectors.


i) Create integer, double, logical, character and complex vectors
ii) Print all vector elements
iii) Print 5th element
iv) Find element type of vector
v) Find length of vector
2. Write R commands for vectors
i)Create two vectors in R
x= (20,30,60,90,100) and y= (2,3,5,7,11,13)
ii) Print sum(x>5)
iii) Print sum(x[x>5])
iv)Print (sum(x>5 | x< 3)
vi)Print y[2:4]
3. . The mileage track for 6 fill-ups were given
65311 65624 65908 66219 66499 66821 67145 67447
Write R commands
i)Create vector for the given data
ii) Print how much miles you travelled between 6 fill ups
iii)Print the maximum and minimum distance travelled
iv) Print average distance travelled within 6 fill ups
v)Print the elements in descending order
4. Your Electricity bill varies from month to month. Suppose your year has the following
monthly amounts
460 330 500 600 460 300 480 320 490 350 300 480
Write R program
i) to enter this data into a vector called bill.
ii) Use the sum command to find the amount you spent this year
iii) What is the smallest amount you spent in a month?
iv) What is the largest?
v) How many months was the amount greater than 400?
5. Write a R program to find arithmetic mean ,geometric mean and harmonic mean for the
given data 2,9,8,4,7,6
6.Write a R program
i) To find the quartiles Q1, Q2, and Q3 of the following data 20, 30, 25, 23, 22, 32, 36
ii) To find the percentiles P8, P50, and P85 of the following data 20, 30, 25, 23, 22, 32, 36
7. .Write a R program using function to check given number is palindrome or not
8.Write a R program to find number of permutations of the letters of the word COLLEGE
9.Write a R program to calculate S= 1+x+x2+x3+……………. xn
10. Write R commands for vectors.
i) Create a list of 5 students with student id, student name, and mode
ii) Print the list
iii) Access top level components
iv) Accessing inner level components
v) Print other than 2nd element
11. Write R commands for vectors.
i) Create a 4x 3 matrix
ii) Display row wise
iii) Access 2nd row and 3rd column element
iv) Access entire row and 2nd column
v) Access entire column and 3rd row
12. Write R commands for vectors.
i) Create a data frame of players with name of the player, name of the sport, name of the
country, age of the players
ii) Display the details
iii) Accessing using []
iv) Accessing using [[]]
v) Accessing using $
13. Write a R script to apply all r operators
1. Creation of two vectors
2. Evaluating the expression x=(a+b)*(c-d)
3. Arithmetic operators on two vectors
4. Relational operators on two vectors
5. Logical operators on two vectors
14. Write an R program to create a list containing a vector, a matrix and a list and give
names to the elements in the list access the first and second element of the list
15. Write a R program to create a list containing a vector, a matrix, and a list and remove
the second element
16. Write an R program to select second element of a given nested list
17. Write an R program to create a user defined function that checks whether a number is
even or not
18. Write an R program to create a user defined function to calculate area of rectangle
19. Write a R program to create a pie chart to depict the students preference in choosing
medical,engineering,arts, science and architecture
20. Write an R program to create a bar chart to depict the results of school for past five
years
21. Write an R program to create a histogram to depict heights of the students in a given
class
22. Write an R program to create a Line chart depicting the sales of a particular product
for past five years.
23. Write an R program to create a 5x4 matrix, 3x3 matrix with labels and fill the matrix
by rows and 2x2 matrix with labels and fill the matrix by columns
24. Write an R program to create a matrix from a list of given vectors
25. Write an R program to concatenate two given matrices of same column but different
rows
26. Write an R program to find row and column index of maximum and minimum value
in a given matrix
27. Write an R program to create a dataframe from four given vectors
28. Write an R program to create a dataframe using two given vectors and display the
duplicated elements and unique rows of the said dataframe
29. Write a R Program to generate Arithmetic Mean and Geometric Mean
30. Write a R Program using all apply() functions

You might also like