game <- c ('game of life')
User <- c('skipper','cowalsky','ricko','mark','vin')
poin <- c(370, 1100, 138, 890, 300)
level <- factor(c('normal','another','easy','hard','normal'))
group <- data.frame(game,User,poin,level)
str(group)
## 'data.frame':    5 obs. of  4 variables:
##  $ game : chr  "game of life" "game of life" "game of life" "game of life" ...
##  $ User : chr  "skipper" "cowalsky" "ricko" "mark" ...
##  $ poin : num  370 1100 138 890 300
##  $ level: Factor w/ 4 levels "another","easy",..: 4 1 2 3 4
summary(group)
##      game               User                poin            level  
##  Length:5           Length:5           Min.   : 138.0   another:1  
##  Class :character   Class :character   1st Qu.: 300.0   easy   :1  
##  Mode  :character   Mode  :character   Median : 370.0   hard   :1  
##                                        Mean   : 559.6   normal :2  
##                                        3rd Qu.: 890.0              
##                                        Max.   :1100.0
group[1:5,]#untuk menampilkan data dengan [baris:kolom, ]
##           game     User poin   level
## 1 game of life  skipper  370  normal
## 2 game of life cowalsky 1100 another
## 3 game of life    ricko  138    easy
## 4 game of life     mark  890    hard
## 5 game of life      vin  300  normal
group[1:5, 2:4,]
##       User poin   level
## 1  skipper  370  normal
## 2 cowalsky 1100 another
## 3    ricko  138    easy
## 4     mark  890    hard
## 5      vin  300  normal
group['level']#bisa juga memanggil dengan nama variabel (data frame)
##     level
## 1  normal
## 2 another
## 3    easy
## 4    hard
## 5  normal
group$level#bisa juga menggunakan slice data dengan $ (format faktor)
## [1] normal  another easy    hard    normal 
## Levels: another easy hard normal

bisa juga mengecek tipe dengan menggunakan class ( ).

class(group['level'])
## [1] "data.frame"
class(group$level)
## [1] "factor"

subset ( ), untuk mengambil data dengan kategori tertentu.

subset(group, level == 'normal')
##           game    User poin  level
## 1 game of life skipper  370 normal
## 5 game of life     vin  300 normal
subset(group, poin >= 350)
##           game     User poin   level
## 1 game of life  skipper  370  normal
## 2 game of life cowalsky 1100 another
## 4 game of life     mark  890    hard