Professional Documents
Culture Documents
Date of Allotment: 6th Sep 2017 Date of submission: 12th Sep 2017
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:
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)
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=
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
Command= Rajawat$Location<-NULL
Result =
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 = choose.files()
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