install.packages(c("ggplot2movies","openxlsx","pacman","dplyr"))
## Installing packages into '/usr/local/lib/R/site-library'
## (as 'lib' is unspecified)
library(openxlsx)
library(ggplot2movies)
library(pacman)
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
#1
p_load(ggplot2movies)
head(movies)
## # A tibble: 6 x 24
##   title  year length budget rating votes    r1    r2    r3    r4    r5    r6
##   <chr> <int>  <int>  <int>  <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 $      1971    121     NA    6.4   348   4.5   4.5   4.5   4.5  14.5  24.5
## 2 $100…  1939     71     NA    6      20   0    14.5   4.5  24.5  14.5  14.5
## 3 $21 …  1941      7     NA    8.2     5   0     0     0     0     0    24.5
## 4 $40,…  1996     70     NA    8.2     6  14.5   0     0     0     0     0  
## 5 $50,…  1975     71     NA    3.4    17  24.5   4.5   0    14.5  14.5   4.5
## 6 $pent  2000     91     NA    4.3    45   4.5   4.5   4.5  14.5  14.5  14.5
## # … with 12 more variables: r7 <dbl>, r8 <dbl>, r9 <dbl>, r10 <dbl>,
## #   mpaa <chr>, Action <int>, Animation <int>, Comedy <int>, Drama <int>,
## #   Documentary <int>, Romance <int>, Short <int>
select1<-select(movies,title:votes,Action:Short)
head(select1)
## # A tibble: 6 x 13
##   title  year length budget rating votes Action Animation Comedy Drama
##   <chr> <int>  <int>  <int>  <dbl> <int>  <int>     <int>  <int> <int>
## 1 $      1971    121     NA    6.4   348      0         0      1     1
## 2 $100…  1939     71     NA    6      20      0         0      1     0
## 3 $21 …  1941      7     NA    8.2     5      0         1      0     0
## 4 $40,…  1996     70     NA    8.2     6      0         0      1     0
## 5 $50,…  1975     71     NA    3.4    17      0         0      0     0
## 6 $pent  2000     91     NA    4.3    45      0         0      0     1
## # … with 3 more variables: Documentary <int>, Romance <int>, Short <int>
#2
movies %>%
  select(starts_with("r"), starts_with("m"))
## # A tibble: 58,788 x 13
##    rating    r1    r2    r3    r4    r5    r6    r7    r8    r9   r10 Romance
##     <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>   <int>
##  1    6.4   4.5   4.5   4.5   4.5  14.5  24.5  24.5  14.5   4.5   4.5       0
##  2    6     0    14.5   4.5  24.5  14.5  14.5  14.5   4.5   4.5  14.5       0
##  3    8.2   0     0     0     0     0    24.5   0    44.5  24.5  24.5       0
##  4    8.2  14.5   0     0     0     0     0     0     0    34.5  45.5       0
##  5    3.4  24.5   4.5   0    14.5  14.5   4.5   0     0     0    24.5       0
##  6    4.3   4.5   4.5   4.5  14.5  14.5  14.5   4.5   4.5  14.5  14.5       0
##  7    5.3   4.5   0     4.5   4.5  24.5  24.5  14.5   4.5   4.5  14.5       0
##  8    6.7   4.5   4.5   4.5   4.5   4.5  14.5  14.5  14.5   4.5  14.5       0
##  9    6.6   4.5   4.5   4.5   0     0     0    34.5  14.5   4.5  24.5       0
## 10    6     4.5   0     4.5   4.5   4.5  44.5  14.5   4.5   4.5   4.5       0
## # … with 58,778 more rows, and 1 more variable: mpaa <chr>
#3
irisImperial<- iris %>% mutate(Species = toupper(Species),
                               Sepal.Width = Sepal.Width/2.5,
                               Sepal.Length = Sepal.Length/2.5,
                               Petal.Width = Petal.Width/2.5,
                               Petal.Length = Petal.Length/2.5)
head(irisImperial)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1         2.04        1.40         0.56        0.08  SETOSA
## 2         1.96        1.20         0.56        0.08  SETOSA
## 3         1.88        1.28         0.52        0.08  SETOSA
## 4         1.84        1.24         0.60        0.08  SETOSA
## 5         2.00        1.44         0.56        0.08  SETOSA
## 6         2.16        1.56         0.68        0.16  SETOSA