-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions_rPrac.R
78 lines (62 loc) · 1.18 KB
/
Functions_rPrac.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
manoj<-function(arg_1,arg2){
for (i in 1:arg_1){
print(i)
}
print(paste('hello',arg2))
return(arg_1+arg2)
}
print(manoj(4,6) )
normd<-rnorm(1000,1,10)
mean(normd)
hist(normd,50)
v<-"I am global variable"
#Switch function
HRA<-function(city){
hra_amt<-switch (toupper(city),
BLR = 7500,
MUM = 1000,
DEL = 8000,
CHN = 7500,
5000
)
return(hra_amt)
}
HRA('blr')
#Repeat
time<-15
repeat{
message('Heloo')
if(time>=20) break
time=time+1
}
#Built In function
x=seq(0,50,2)
x
sort(x,TRUE)
text<-'R is a programming Language for Data science'
grep('Language',text)
# Factors in R
bloodgroup<-c('B','AB',"O","O","A","B",'AB','A')
blood_fac<-factor((bloodgroup))
blood_fac
str(blood_fac)
#Working with timestamps
Sys.Date()
install.packages('dplyr')
library(dplyr)
install.packages('nycflights13')
library('nycflights13')
View(flights)
head(flights)
man<-data.frame(
ID=c(1:6),
Face.1=c(5:10),
Face.2=c(10:15),
Face.3=c(15:20)
)
View(man)
lo<-man%>%gather(face,Rsa,Face.1:Face.3)
View(lo)
mul<-lo%>%separate(face,c("Target","Number"))
View(mul)
plot(ChickWeight)