-
Notifications
You must be signed in to change notification settings - Fork 0
/
built in function in R.R
86 lines (45 loc) · 1.05 KB
/
built in function in R.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
79
80
81
82
83
84
85
86
# built in functions in R
x<--4
# 1st built in funct.--> abs() ye absolute value ko print karega.
print(abs(x))
# 2nd--> sqrt() it will print sqare root .
print(sqrt(45))
# ceiling funct.
x<-5.6
print(ceiling(x))
print(floor(x))
#truncate funct.
x<-c(1.5,5.6,8.6)
print(trunc(x))
#sin and cos funct.
y<-5
print(sin(y))
# log function.
print(log(y))
# exponent funct.
print(exp(y))
# string related function:
# substring funct.
a<-"123456789"
substr(a,2,7)
b<-"sterueoa67sdgadg54"
substr(b,6,5)
# conversion of string from upper to lower or lower to upper.
s1<-"krishna uprit"
print(toupper(s1))
s2<-"KRISHNA UPRIT"
print(tolower(s2))
# grep: it searches the pattern in string.
s3<-c('abcd','bcd', 'acbd', 'adbccdba')
pat<-'^bcb'
print(grep(pat,s3))
a1<-c(0:10,23,32,15)
su<-sum(a1)
print(su)
# min and max funct.
a1<-c(0:10,23,32,15)
su<-min(a1)
print(su)
a1<-c(0:10,23,32,15)
su<-max(a1)
print(su)