This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
x<- c(4,8,1,2)
x
## [1] 4 8 1 2
x<- c(1,1,2,1)
x
## [1] 1 1 2 1
z<- c(4,5,3,2,3,4,5,6,3,4,5,5,6,7,7,4,3,2,2,3,4,5,6,7,8,4,3,2,5)
z
## [1] 4 5 3 2 3 4 5 6 3 4 5 5 6 7 7 4 3 2 2 3 4 5 6 7 8 4 3 2 5
x<- c(4,8,1,2)
x[1]
## [1] 4
x[2]
## [1] 8
x[4]
## [1] 2
x<-c(4,8,1,2)
x
## [1] 4 8 1 2
x[1]
## [1] 4
x[1]<-100000
x[1]
## [1] 1e+05
x[2]
## [1] 8
x[2]<-12
x[2]
## [1] 12
x<-c(1,2,3,4,5,6)
y<-c(2,3,4,5,6)
z<-x
z
## [1] 1 2 3 4 5 6
z<-c(y)
z
## [1] 2 3 4 5 6
z=x
z
## [1] 1 2 3 4 5 6
x<-1
x
## [1] 1
y<-5
y
## [1] 5
y=4
y
## [1] 4
x<-c(1,2,3)
x
## [1] 1 2 3
x->y
y
## [1] 1 2 3
assign("z",y)
z
## [1] 1 2 3
assign("a",c(1,2,3,4,5,6,7,8))
a
## [1] 1 2 3 4 5 6 7 8
b=a
b
## [1] 1 2 3 4 5 6 7 8
x<- c(4,5,2,1,9,8,5,6,10,13)
y<- c(1,2,6)
z<-c(9,3,4,5)
x
## [1] 4 5 2 1 9 8 5 6 10 13
x[4]
## [1] 1
x[c(1,3)]
## [1] 4 2
x[c(8,10)]
## [1] 6 13
x[-c(1,2,3,4,5)]
## [1] 8 5 6 10 13
x[3:7]
## [1] 2 1 9 8 5
x[-3]
## [1] 4 5 1 9 8 5 6 10 13
x[c(-3)]
## [1] 4 5 1 9 8 5 6 10 13
x[y]
## [1] 4 5 8
x[-y]
## [1] 2 1 9 5 6 10 13
x[z]
## [1] 10 2 1 9
z[-z]
## [1] 9 3
x<-c(1,5,3,6,7)
length(x)
## [1] 5
y<-c(4,4,5,4)
length(y)
## [1] 4
c<- vector (length=2)
length(c)
## [1] 2
c
## [1] FALSE FALSE
mode (c)
## [1] "logical"
c[1] <-4
c[2]<-12
c
## [1] 4 12
mode (c)
## [1] "numeric"
A <-vector (length=5)
length(A)
## [1] 5
A
## [1] FALSE FALSE FALSE FALSE FALSE
mode(A)
## [1] "logical"
A[2]=40000
A
## [1] 0 40000 0 0 0
mode(A)
## [1] "numeric"
A<-c(4,5,3)
A
## [1] 4 5 3
mode(A)
## [1] "numeric"
B<-c ("ugi","egi","ronnie")
B
## [1] "ugi" "egi" "ronnie"
mode(B)
## [1] "character"
C<-c(TRUE,FALSE,TRUE)
C
## [1] TRUE FALSE TRUE
mode(C)
## [1] "logical"
X<-c(1,2,3,4)
X
## [1] 1 2 3 4
Y<-c(2,3,4,1)
Y
## [1] 2 3 4 1
Z<-x+y
## Warning in x + y: longer object length is not a multiple of shorter object
## length
Y<-c(Z)
Y
## [1] 5 9 8 10 11
X*Y
## Warning in X * Y: longer object length is not a multiple of shorter object
## length
## [1] 5 18 24 40 11
X<-c(1,2,3)
Y<-c(3,2,1)
X+Y
## [1] 4 4 4
X-Y
## [1] -2 0 2
X*Y
## [1] 3 4 3
X/Y
## [1] 0.3333333 1.0000000 3.0000000
X^Y
## [1] 1 4 3
X%%Y
## [1] 1 0 0
5^2
## [1] 25
9%%4
## [1] 1
9%%5
## [1] 4
9%%6
## [1] 3
2*X
## [1] 2 4 6
2*Y
## [1] 6 4 2
-5%%3
## [1] 1
-5%%4
## [1] 3
x <- c(1,2,3,4,5)
names(x)<-c("Sangat Tidak Puas", "Tidak puas", "Biasa Aja", "Puas", "Sangat Puas")
x
## Sangat Tidak Puas Tidak puas Biasa Aja Puas
## 1 2 3 4
## Sangat Puas
## 5
x["Tidak Puas"]
## <NA>
## NA
names(x)<-NULL
x
## [1] 1 2 3 4 5
x<-c(5,4,3,5)
x[1]
## [1] 5
x[2]
## [1] 4
x[3]
## [1] 3
x[4]
## [1] 5
x[5]
## [1] NA
x[6]
## [1] NA
x<-c(5,4,3,5)
x
## [1] 5 4 3 5
x<-x[-2]
x
## [1] 5 3 5
y<-c(3,4,5,7,8,2,10)
y
## [1] 3 4 5 7 8 2 10
y<-y[-c(3,6,7)]
y
## [1] 3 4 7 8