You are on page 1of 11

Annexure-V- Cover Page for Academic Tasks

Course Code: MGN619 Course Title: Business Analytics

Course Instructor: Kriti Bedi

Academic Task No.: CA1 Academic Task Title: Test

Date of Allotment: 6th Sep 2017 Date of submission: 12th Sep 2017

Students Name: Raveena Rajawat Students Reg. no:11604638

Evaluation Parameters: (Parameters on which student is to be evaluated- To be mentioned by


students as specified at the time of assigning the task by the instructor)

Learning Outcomes: Got to know about that how command in R software works and where to apply the
same.

Declaration:

I declare that this Assignment is my individual work. I have not copied it from any other students
work or from any other source except where due acknowledgement is made explicitly in the text, nor
has any part been written for me by any other person.

Students
Signature:

Evaluatorscomments (For Instructors use only)

General Observations Suggestions for Improvement Best part of assignment

Evaluators Signature and Date:

Marks Obtained: Max. Marks:


1. Create 5 hypothetical vectors with 28 observations, of which at least 2 should be a
character vector (one of the vector name should be first name of the student).

Ans.
Firstname=c("ram","shyam","gopal","sunny","mohit","rohit","divya","rohan","tarun","k
alpana","prem","shubham","bobby","poonam","lalita","annu","piyush","ajay","yogesh","
naveen","nisha","vicky","chinu","kavita","bindu","alisha","soniya","nirmla")

Lastname=c("avtar","chaturvedi","goel","sharma","Kaushik","Raghav","rathore","rajwat
","shekawat","shah","kumari","pal","sinhg","rathi","chauhan","tanwar","tawar","malik","
jadeja","tiwari","rawat","kaushik","rajawat","singh","kaur","salathia","dhillon","devi")

Regstration=c(12345,12346,12347,12348,12349,12350,12351,12352,12353,12354,1235
5,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,1236
8,12369,12370,12371,12372)

CGPA=c(7.6,6.9,6.5,8,9.2,7.9,4.9,6.5,7,9,10,9.8,6.8,7.3,6.8,5.2,7.4,6.4,9.1,5.7,8.1,8.3,8.5
,6.2,8.7,3.4,7.6,5)

Mobile=c(8675086879,9875403456,8976124567,9878353587,7654312233,8787851237,
7685356850,7825736271,9864572356,8765232563,9856427561,8737415796,874864931
5,7862349087,7852574209,9843731590,9090876543,8976253509,9876543345,8656055
456,7887543436,8765654504,9578985780,8536568797,7523658950,9743664765.75434
56664,8332356577)
Firstname (ctrl+r)

Lastname (ctrl+r)

Regstration (ctrl+r)

CGPA (ctrl+r)

Mobile (ctrl+r)
2. Create a data frame for the vectors created (Name of the data frame should be
surname of the student).
Ans.
Rajawat=data.frame(Firstname,Lastname,Regstration,CGPA,Mobile) (ctrl+r)
View(Rajawat) (ctrl+r)

Firstname Lastname Regstration CGPA Mobile

1 ram avtar 12345 7.6 8675086879


2 shyam chaturvedi 12346 6.9 9875403456
3 gopal goel 12347 6.5 8976124567
4 sunny sharma 12348 8 9878353587
5 mohit Kaushik 12349 9.2 7654312233
6 rohit Raghav 12350 7.9 8787851237
7 divya rathore 12351 4.9 7685356850
8 rohan rajwat 12352 6.5 7825736271
9 tarun shekawat 12353 7 9864572356
10 kalpana shah 12354 9 8765232563
11 prem kumari 12355 10 9856427561
12 shubham pal 12356 9.8 8737415796
13 bobby sinhg 12357 6.8 8748649315
14 poonam rathi 12358 7.3 7862349087
15 lalita chauhan 12359 6.8 7852574209
16 annu tanwar 12360 5.2 9843731590
17 piyush tawar 12361 7.4 9090876543
18 ajay malik 12362 6.4 8976253509
19 yogesh jadeja 12363 9.1 9876543345
20 naveen tiwari 12364 5.7 8656055456
21 nisha rawat 12365 8.1 7887543436
22 vicky kaushik 12366 8.3 8765654504
23 chinu rajawat 12367 8.5 9578985780
24 kavita singh 12368 6.2 8536568797
25 bindu kaur 12369 8.7 7523658950
26 alisha salathia 12370 3.4 9743664766
27 soniya dhillon 12371 7.6 8332356577
28 nirmla devi 12372 5 9865425642
3. Write a command to display the top and bottom 6 observation in the data frame you
created.
Command= head(Rajawat) (ctrl+r)

Result
Firstname Lastname Regstration CGPA Mobile
1 ram avtar 12345 7.6 8675086879
2 shyam chaturvedi 12346 6.9 9875403456
3 gopal goel 12347 6.5 8976124567
4 sunny sharma 12348 8.0 9878353587
5 mohit Kaushik 12349 9.2 7654312233
6 rohit Raghav 12350 7.9 8787851237

Command (for last 6 observations) = tail(Rajawat) (ctrl+r)


Result
Firstname Lastname Regstration CGPA Mobile
23 chinu rajawat 12367 8.5 9578985780
24 kavita singh 12368 6.2 8536568797
25 bindu kaur 12369 8.7 7523658950
26 alisha salathia 12370 3.4 9743664766
27 soniya dhillon 12371 7.6 8332356577
28 nirmla devi 12372 5.0 9865425642

4. Create and insert a new vector in the data frame created.

Command=
Location=c("HR","UP","UP","PB","GJ","PB","PB","MP","DL","PB","AP","GJ","MH","
HR","NEPAL","CHD","KL","JK","DL","RJ","DL","JK","HR","KL","KOL","BIHAR","
AP","BHU")

Rajawat["Location"]=Location

Firstname Lastname Regstration CGPA Mobile Location


1 ram avtar 12345 7.6 8675086879 HR
2 shyam chaturvedi 12346 6.9 9875403456 UP
3 gopal goel 12347 6.5 8976124567 UP
4 sunny sharma 12348 8 9878353587 PB
5 mohit Kaushik 12349 9.2 7654312233 GJ
6 rohit Raghav 12350 7.9 8787851237 PB
7 divya rathore 12351 4.9 7685356850 PB
8 rohan rajwat 12352 6.5 7825736271 MP
9 tarun shekawat 12353 7 9864572356 DL
10 kalpana shah 12354 9 8765232563 PB
11 prem kumari 12355 10 9856427561 AP
12 shubham pal 12356 9.8 8737415796 GJ
13 bobby sinhg 12357 6.8 8748649315 MH
14 poonam rathi 12358 7.3 7862349087 HR
15 lalita chauhan 12359 6.8 7852574209 NEPAL
16 annu tanwar 12360 5.2 9843731590 CHD
17 piyush tawar 12361 7.4 9090876543 KL
18 ajay malik 12362 6.4 8976253509 JK
19 yogesh jadeja 12363 9.1 9876543345 DL
20 naveen tiwari 12364 5.7 8656055456 RJ
21 nisha rawat 12365 8.1 7887543436 DL
22 vicky kaushik 12366 8.3 8765654504 JK
23 chinu rajawat 12367 8.5 9578985780 HR
24 kavita singh 12368 6.2 8536568797 KL
25 bindu kaur 12369 8.7 7523658950 KOL
26 alisha salathia 12370 3.4 9743664766 BIHAR
27 soniya dhillon 12371 7.6 8332356577 AP
28 nirmla devi 12372 5 9865425642 BHU

5. Remove the newly created vector from the data frame.

Command= Rajawat$Location<-NULL

Result =

Firstname Lastname Regstration CGPA Mobile

1 ram avtar 12345 7.6 8675086879


2 shyam chaturvedi 12346 6.9 9875403456
3 gopal goel 12347 6.5 8976124567
4 sunny sharma 12348 8 9878353587
5 mohit Kaushik 12349 9.2 7654312233
6 rohit Raghav 12350 7.9 8787851237
7 divya rathore 12351 4.9 7685356850
8 rohan rajwat 12352 6.5 7825736271
9 tarun shekawat 12353 7 9864572356
10 kalpana shah 12354 9 8765232563
11 prem kumari 12355 10 9856427561
12 shubham pal 12356 9.8 8737415796
13 bobby sinhg 12357 6.8 8748649315
14 poonam rathi 12358 7.3 7862349087
15 lalita chauhan 12359 6.8 7852574209
16 annu tanwar 12360 5.2 9843731590
17 piyush tawar 12361 7.4 9090876543
18 ajay malik 12362 6.4 8976253509
19 yogesh jadeja 12363 9.1 9876543345
20 naveen tiwari 12364 5.7 8656055456
21 nisha rawat 12365 8.1 7887543436
22 vicky kaushik 12366 8.3 8765654504
23 chinu rajawat 12367 8.5 9578985780
24 kavita singh 12368 6.2 8536568797
25 bindu kaur 12369 8.7 7523658950
26 alisha salathia 12370 3.4 9743664766
27 soniya dhillon 12371 7.6 8332356577
28 nirmla devi 12372 5 9865425642

6. Display the values of the second column and all rows.

Command = Rajawat[,2}

Result =
7. Print the summary of the statistics.
Command = summary(Rajawat) (ctrl+r)

8. Create the subset using the data except 7th and 9th row and 2nd to 3rd column of the
data set.

Command = Rajawat[-c(7,9),c(2:3)]

Lastname Regstration
1 avtar 12345
2 chaturvedi 12346
3 goel 12347
4 sharma 12348
5 Kaushik 12349
6 Raghav 12350
8 rajwat 12352
10 shah 12354
11 kumari 12355
12 pal 12356
13 sinhg 12357
14 rathi 12358
15 chauhan 12359
16 tanwar 12360
17 tawar 12361
18 malik 12362
19 jadeja 12363
20 tiwari 12364
21 rawat 12365
22 kaushik 12366
23 rajawat 12367
24 singh 12368
25 kaur 12369
26 salathia 12370
27 dhillon 12371
28 devi 12372
9. Create the subset using the values in row 3, columns 2 through 5.

Command = Rajawat[3,2:5]

10. Write a command to know the class of the object you are working with.

Command & Result

11. Write a command to find the location of the file.

Command = choose.files()

Result = "C:\\Users\\Dell\\Documents\\r Assignment.docx"

12. Create a CSV file containing the two vectors with 5 observations and import this file
in R.
Command = read.csv(choose.files())
Result
13. Create a new vector doing a sum of two vectors created in question 1.
Command = Rajawat=(Regstration+Mobile)

Rajawat

14. Create a character object with your name and then convert it into numeric data
using nested commands.
Command = Ravina=c("chinu","baby","shubham")
Ravina1=as.numeric(as.factor(Ravina))
Ravina1

15. Create a matrix of 5X5 with hypothetical values and where row name should be first
character of your name and columns name should be first character of surname.
(For Ex. If name is Kriti Bedi then Row names should be K1, K2, K3, K4,K5 and
columns name should be B1, B2, B3,B4,B5).

Command =
R1=c("Ravina","Kavita","Shubham","Kalpana","Prempal")
R2=c(21,19,12,39,49)
R3=c("Jalandhar","Nashik","Mumbai","Pune","Pune")
R4=c(1111,2222,3333,4444,5555)
R5=c("kheer","Jammun","Choclate","Icecream","Barfi")
RS1=data.frame(R1,R2,R3,R4,R5)
row.names(RS1)=c("R1","R2","R3","R4","R5")
colnames(RS1)=c("S1","S2","S3","S4","S5")
RS1

You might also like