library(tidyquant)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## ── Attaching core tidyquant packages ──────────────────────── tidyquant 1.0.9 ──
## ✔ PerformanceAnalytics 2.0.4 ✔ TTR 0.24.4
## ✔ quantmod 0.4.26 ✔ xts 0.14.0
## ── Conflicts ────────────────────────────────────────── tidyquant_conflicts() ──
## ✖ zoo::as.Date() masks base::as.Date()
## ✖ zoo::as.Date.numeric() masks base::as.Date.numeric()
## ✖ PerformanceAnalytics::legend() masks graphics::legend()
## ✖ quantmod::summary() masks base::summary()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:xts':
##
## first, last
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(readxl)
bikes <- read_excel("bikes.xlsx")
bikes %>%
select(model, price)
## # A tibble: 97 × 2
## model price
## <chr> <dbl>
## 1 Supersix Evo Black Inc. 12790
## 2 Supersix Evo Hi-Mod Team 10660
## 3 Supersix Evo Hi-Mod Dura Ace 1 7990
## 4 Supersix Evo Hi-Mod Dura Ace 2 5330
## 5 Supersix Evo Hi-Mod Utegra 4260
## 6 Supersix Evo Red 3940
## 7 Supersix Evo Ultegra 3 3200
## 8 Supersix Evo Ultegra 4 2660
## 9 Supersix Evo 105 2240
## 10 Supersix Evo Tiagra 1840
## # ℹ 87 more rows
bikes %>%
arrange(desc(1:97))
## # A tibble: 97 × 4
## bike.id model description price
## <dbl> <chr> <chr> <dbl>
## 1 97 Catalyst 4 Mountain - Sport - Aluminum 415
## 2 96 Catalyst 3 Mountain - Sport - Aluminum 480
## 3 95 Catalyst 2 Mountain - Sport - Aluminum 585
## 4 94 Catalyst 1 Mountain - Sport - Aluminum 705
## 5 93 Trail 5 Mountain - Sport - Aluminum 815
## 6 92 Trail 4 Mountain - Sport - Aluminum 980
## 7 91 Trail 3 Mountain - Sport - Aluminum 1080
## 8 90 Trail 2 Mountain - Sport - Aluminum 1350
## 9 89 Trail 1 Mountain - Sport - Aluminum 1520
## 10 88 Habit 6 Mountain - Trail - Aluminum 1950
## # ℹ 87 more rows
bikes %>%
filter(1:97 > mean(1:97, na.rm = TRUE))
## # A tibble: 48 × 4
## bike.id model description price
## <dbl> <chr> <chr> <dbl>
## 1 50 Jekyll Carbon 4 Mountain - Over Mountain - Carbon 3200
## 2 51 Trigger Carbon 1 Mountain - Over Mountain - Carbon 8200
## 3 52 Trigger Carbon 2 Mountain - Over Mountain - Carbon 5970
## 4 53 Trigger Carbon 3 Mountain - Over Mountain - Carbon 3730
## 5 54 Trigger Carbon 4 Mountain - Over Mountain - Carbon 3200
## 6 55 Scalpel-Si Black Inc. Mountain - Cross Country Race - Carbon 12790
## 7 56 Scalpel-Si Race Mountain - Cross Country Race - Carbon 9060
## 8 57 Scalpel-Si Hi-Mod 1 Mountain - Cross Country Race - Carbon 7460
## 9 58 Scalpel-Si Carbon 2 Mountain - Cross Country Race - Carbon 6390
## 10 59 Scalpel-Si Carbon 3 Mountain - Cross Country Race - Carbon 5330
## # ℹ 38 more rows