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

Introduction To R Programming PYQ 2022 by CSHUB

DU PYQ

Uploaded by

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

Introduction To R Programming PYQ 2022 by CSHUB

DU PYQ

Uploaded by

anjansingh100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
+ Introduction to R Programming (SEC) : B.Sc. (H) Computer Science = TY: Maximum Marks : 25 V— Write your Roll No. on the top immediately on receipt of this question paper. ‘All parts of Question 1 (Part A) are compulsory. Attempt any three questions from Part B. a, All questions in Part B carry equal marks. Ua - (by Write R statement to extract the fows from a data frame “df” that does not have missing : a) (c) Write the output for statements 1 and 2 in the following R script. ¥ < e(2, 1,5, 7, 8,3, 2,4, 5) tength(y} <4 printty) ®statement | length(y) Printly) #statement 2 Q) (d) For the given factor f <- factor(e(“abe", “abe”, "cab", “bac", “abe”, “cab”, “cab")), what will table(f) return? (2) te} What are the two compulsory files in a package directory structure” (2) (2) What is the difference between the functions “ead.esv” and “read.csy2"? (2) 1029 3 PART B 2. Consider ‘Student’ table in a MySQL database ‘dbl’: Student(roll_no, name, city, course) Write R script to perform the following tasks (i) Load relevant packages to conmect with the database. (ii) Establish the connection with the “dbl” database, (iii) Display all tables of the database “dbl” (iv) Display the total number of students from the “Student” table. (¥) Close the database connection, (3) 3. (a) Write output for the following command © (2) switch (5% /%2, sum(2:8), summary(e(“a", “b")), sample(10, 5)) (b) Given a list L as: Ls list a=2, b=}, twin = of trip = of PTO 1029 4 What will be the output of following R tatomeny, () unlist(L) . (i) lapply(L, length) 44) sapply(L, length) Q) 4 Consider the following data frame “df” (+2 , +242) ; Write R seript to perform the following : (1) Display the rows of “df where Class is “A 6) Display the total values for each class 1029 5 (iii) Create a suitable plot to show the statistics! summary of all values with respeci to (heir class. $. (a) Given a data frame “rect” contamning the length: and breadth of five rectangles and a function “rect_area”™ to compute the area of rectangles as rect <+ datuiframe(Lme(i0, $:5,.6, 718, 7) Beo(6, 4, 1.2, 3.49) rect_atea <+ function(a, b) { atb Write an R statement to create @ piekage called compute the area of rectangles using “my area” to ond given dato frame and function, (b) For the givem vectors y7 and “Ty”, x <= matrix(rep( 3, cach =2), nrow=3. nev yet matrixtrep(l:3, fength out=6). BF vw? 1029 6 What will be the output of W) x 8% y (i) x © uy) Pa 6. Consider the following dataset that shows the number of times the tasks $ are performed by either P1, p2 er jointly by PT and P2; \ ‘Cleaning Dishes g to | Finarices Daving I Hondaya Write RB seript to: (1) Find the tasks which are performed more by the PI than the P2 4029 1 (ii) Display the tasks that are jointly performed by Pi and P2. (iii) Give a suitable plot to show the frequency of each task performed by Pl and P2. Give appropriate labels and legends 7 (a) Write R seript to read a file “my_file.txt™: (i) headers as in input file, (ii) separator as new line character, (iii) indicate blank rows as missing values, (iv) quoting strings as **. () @) (b) What will be the output of *£(S)°? Function “ft de f< fined as follows : ~ function(s) f <- funetion(x) 1029 8 print(x*2) } f(x) + 1

You might also like