Import the data files using read_excel()to import excel files.
library("readxl")
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
library("tidyverse")
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.4
## ✔ ggplot2 3.4.3 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library("lubridate")
library("writexl")
bike_data <- read_excel("/cloud/project/bikes.xlsx")
Show “model” and “price” columns,sorted by “price” in descending
order
task_1_sorted_bike<- bike_data %>%
select(model,price) %>%
arrange(desc(price))
Calculate the mean price
mean_price <- mean(bike_data$price)
Show “model” and “price” columns with condition”price”
task_2_high_price_bike <- bike_data %>%
select(model,price) %>%
filter(price>mean_price)