Import dataset

#install.packages("readxl")
library(readxl)
pokemon<-read_excel("Pokemon.xlsx")
head(pokemon)
## # A tibble: 6 x 11
##   Name  `Type 1` `Type 2` Total    HP Attack Defense `Sp. Atk` `Sp. Def`
##   <chr> <chr>    <chr>    <dbl> <dbl>  <dbl>   <dbl>     <dbl>     <dbl>
## 1 Bulb… Grass    Poison     318    45     49      49        65        65
## 2 Ivys… Grass    Poison     405    60     62      63        80        80
## 3 Venu… Grass    Poison     525    80     82      83       100       100
## 4 Venu… Grass    Poison     625    80    100     123       122       120
## 5 Char… Fire     <NA>       309    39     52      43        60        50
## 6 Char… Fire     <NA>       405    58     64      58        80        65
## # … with 2 more variables: Speed <dbl>, Generation <dbl>

This dataset contains a list Pokemon with statistics.

Summary Table

summary(pokemon)
##      Name              Type 1             Type 2              Total      
##  Length:800         Length:800         Length:800         Min.   :180.0  
##  Class :character   Class :character   Class :character   1st Qu.:330.0  
##  Mode  :character   Mode  :character   Mode  :character   Median :450.0  
##                                                           Mean   :435.1  
##                                                           3rd Qu.:515.0  
##                                                           Max.   :780.0  
##        HP             Attack       Defense          Sp. Atk      
##  Min.   :  1.00   Min.   :  5   Min.   :  5.00   Min.   : 10.00  
##  1st Qu.: 50.00   1st Qu.: 55   1st Qu.: 50.00   1st Qu.: 49.75  
##  Median : 65.00   Median : 75   Median : 70.00   Median : 65.00  
##  Mean   : 69.26   Mean   : 79   Mean   : 73.84   Mean   : 72.82  
##  3rd Qu.: 80.00   3rd Qu.:100   3rd Qu.: 90.00   3rd Qu.: 95.00  
##  Max.   :255.00   Max.   :190   Max.   :230.00   Max.   :194.00  
##     Sp. Def          Speed          Generation   
##  Min.   : 20.0   Min.   :  5.00   Min.   :1.000  
##  1st Qu.: 50.0   1st Qu.: 45.00   1st Qu.:2.000  
##  Median : 70.0   Median : 65.00   Median :3.000  
##  Mean   : 71.9   Mean   : 68.28   Mean   :3.324  
##  3rd Qu.: 90.0   3rd Qu.: 90.00   3rd Qu.:5.000  
##  Max.   :230.0   Max.   :180.00   Max.   :6.000

Summary of Statistics

  • HP
  • Attack
  • Defense
  • Sp. Atk
  • sp. Def
  • Speed
  • Generation

Compute using inline

Can best attacking pokemon kill best defense pokemon?

#install.packages("dplyr") 
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
sub_data<- pokemon %>% select(1,5,6)
sub_data
## # A tibble: 800 x 3
##    Name                         HP Attack
##    <chr>                     <dbl>  <dbl>
##  1 Bulbasaur                    45     49
##  2 Ivysaur                      60     62
##  3 Venusaur                     80     82
##  4 VenusaurMega Venusaur        80    100
##  5 Charmander                   39     52
##  6 Charmeleon                   58     64
##  7 Charizard                    78     84
##  8 CharizardMega Charizard X    78    130
##  9 CharizardMega Charizard Y    78    104
## 10 Squirtle                     44     48
## # … with 790 more rows
strongest_Attack <- sub_data[which.max(sub_data$Attack),]
highest_HP <-sub_data[which.max(sub_data$HP),]

strongest_Attack[,3]-highest_HP[,2]
##   Attack
## 1    -65

Strongest_Attacker can kill pokemon which has highest HP at once.

Including Plots

You can also embed plots, for example:

## # A tibble: 18 x 1
##    `Type 2`
##    <chr>   
##  1 Poison  
##  2 Flying  
##  3 Dragon  
##  4 Ground  
##  5 Fairy   
##  6 Grass   
##  7 Fighting
##  8 Psychic 
##  9 Steel   
## 10 Ice     
## 11 Rock    
## 12 Dark    
## 13 Water   
## 14 Electric
## 15 Fire    
## 16 Ghost   
## 17 Bug     
## 18 Normal
## sub_data3
##      Bug     Dark   Dragon Electric    Fairy Fighting     Fire   Flying 
##        3       20       18        6       23       26       12       97 
##    Ghost    Grass   Ground      Ice   Normal   Poison  Psychic     Rock 
##       14       25       35       14        4       34       33       14 
##    Steel    Water 
##       22       14

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.