Вы находитесь на странице: 1из 10

Commands Packages: R has buit in series of modules called as packages, to find out the packages

 Search()
 3+9+12-7
[1] 17,*
 12+17/2-3/4*2.5
[1] 18.625
 Math operators =,-,/,()
 Pi, sqrt()x),abs(x),facvtorial(x),log(x, base=n), log10(n),log2(x), exp(x),cos,sin,tan(x)
 17/2-3/4*2.5
[1] 18.625
 > pi*2^3-sqrt(4)
[1] 23.13274
 > abs(12-17+2/3-9)
[1] 13.33333
 > factorial(4)
[1] 24
 > log(2,10)
[1] 0.30103
 > log10(2)
[1] 0.30103
 > exp(0.69314)
[1] 1.999986
 > sin(5*pi/180)
[1] 0.08715574
 Storing th result of the calculation
 > a=23+14/2-18+(7*pi/2)
 >a
[1] 22.99557
 > b=13+11+(17-4/7)
 >b
[1] 40.42857
 > c=a+b/2
 >c
[1] 43.20986
 > c=b+9-2+pi
 >c
[1] 50.57016
 > d<-3+5
 >d
[1] 8
which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
 > e<-a+b
 >e

[1] 63.42415
Using scan command to store the values
d4=scan()
1: 6 7 8 9 3 5 6 2 5 6
11: 77 88 99
14: 12 12 12 12 12
19:
Read 18 items
> d4
[1] 6 7 8 9 3 5 6 2 5 6 77 88 99 12 12 12 12 12
d1 = scan(what="character")
1: mon tues wed
4: thurs friday saturday
7:
Read 6 items
> d1
[1] "mon" "tues" "wed" "thurs" "friday"
"saturday"
Using clip board to make data or importing data from excel
file of text file
scan(sep=",")
1: 11,88211,5197,565
5: 11,6766,3445,406
9: 10,2969,69311,867
which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
13: 4,7526,78612,560
17: 10,6995,19410,525
21: 10,4048,9648,964
25: 11,8413,90010,992
29: 5,2596,1837,847
33: 6,3644,6894,759
37:
Read 36 items
[1] 11 88211 5197 565 11 6766 3445 406 10
2969 69311 867
[13] 4 7526 78612 560 10 6995 19410 525 10
4048 9648 964
[25] 11 8413 90010 992 5 2596 1837 847 6 3644
6894 759
> scan(what="chracter0"

+ > scan(what="character")
1: Define meaning and the scope of e-business and e-
commerce. Summarize the main reason for adoption of e-
commerce and e-business and barriers that may restrict
adoption?
26:
Read 25 items
[1] "Define" "meaning" "and" "the" "scope"
[6] "of" "e-business" "and" "e-commerce."
"Summarize"
which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
[11] "the" "main" "reason" "for"
"adoption"
[16] "of" "e-commerce" "and" "e-business"
"and"
[21] "barriers" "that" "may" "restrict"
"adoption?"
> d1
[1] 2 5 7 8 9 3 7 1 9
> d1[1]
[1] 2
> d1[7]
[1] 7
> d1[1:3]
[1] 2 5 7
> d1[-1]
[1] 5 7 8 9 3 7 1 9
> d1[1,5,7]
Error in d1[1, 5, 7] : incorrect number of dimensions
> d1[1,3,5]
Error in d1[1, 3, 5] : incorrect number of dimensions
> d1[d1>5]
which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
[1] 7 8 9 7 9
> d1[d1<3 | d1>7]
[1] 2 8 9 1 9
> length(d1)
[1] 9
> max(d1)
[1] 9
> sort(d1)
[1] 1 2 3 5 7 7 8 9 9
> sort(d1, decreasing=TRUE)
[1] 9 9 8 7 7 5 3 2 1
Creating Data Frames.
> s1=c("Names", "OM", "AFM", "ISM", "FM")
> s2=c("Amit", 45, 66, 67, 23)
> s3=c("Sunil", 55, 56, 74, 88)
> s4=c("Vinny", 45, 56, 67, 56)
> my.frame=data.frame(s1, s2, s3, s4)
> my.frame
s1 s2 s3 s4

which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
1 Names Amit Sunil Vinny
2 OM 45 55 45
3 AFM 66 56 56
4 ISM 67 74 67
5 FM 23 88 56
Descriptive Statistics
> d1
[1] 2 5 7 8 9 3 7 1 9
> mean(d1)
[1] 5.666667
> max(d1)
[1] 9
> min(d1)
[1] 1
> length(d1)
[1] 9
> sd(d1)
[1] 3.041381
> summary(d1)

which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.000 3.000 7.000 5.667 8.000 9.000
Creating HISTOGRAM
1.
> d1=c(3,5,7,5,3,2,6,8,5,6,9,4,5,7,3,4)
> hist(d1)
> table(d1)
d1
23456789
13242211
2.
> hist(d1,
+ col="blue",
+ main="HISTOGRAM",
+ xlab="SIZE CLASS FOR d1",
+ ylab="DENSITI",
+ ylim=c(0, 0.3),
+ freq=FALSE)
CREATING PIE CHART

which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
d1=c(3, 5, 7, 5, 3, 2, 6, 8, 5, 6, 9, 8)
> d1
[1] 3 5 7 5 3 2 6 8 5 6 9 8
> d2=c("Jan", "Feb", "Mar", "April", "May", "June", "July",
"August", "Sep", "OCT", "Nov", "Dec")
> d2
[1] "Jan" "Feb" "Mar" "April" "May" "June" "July"
"August"
[9] "Sep" "OCT" "Nov" "Dec"
> pie(d1, labels=d2)
BAR GRAPHS
1.
rain=c(3, 5, 7, 5, 3, 2, 6, 8, 5, 6, 9, 8)
> rain
[1] 3 5 7 5 3 2 6 8 5 6 9 8
> barplot(rain)
2.
rain ; d2
[1] 3 5 7 5 3 2 6 8 5 6 9 8

which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
[1] "Jan" "Feb" "Mar" "April" "May" "June" "July"
"August"
[9] "Sep" "OCT" "Nov" "Dec"
> rain
[1] 3 5 7 5 3 2 6 8 5 6 9 8
> names(rain)=d2
> rain
Jan Feb Mar April May June July August Sep OCT
Nov
3 5 7 5 3 2 6 8 5 6 9
Dec
8
> barplot(rain)
> title(xlab="MONTHS", ylab="RAINFALL in CM")
Error in title(xlab = "MONTHS", ylab = "RAINFALL in CM") :
plot.new has not been called yet
> barplot(rain, xlab="MONTHS", ylab="RAINFALL IN CM",
ylim=c(0,10))

which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7
which(d1==5)
[1] 2
> which(d1==7)
[1] 3 7

Вам также может понравиться