601HW2

Sheng Zhang
2021/12/26

Read in a dataset

Q1: This dataset is named poultry_tidy.csv which is downloaded from SampleDataset.

Q2: There are four columns in this dataset. Product is the name of production it’s string type. Year and Month are date type. Price_Dollar is numerical type.

Q3: Then we can use filter to select the product which is ‘Whole’ and arrange the rows based on asending Price_Dollar. Finally use slice to select 10 rows with the lowest price.

library(dplyr)
poultry <- read.csv("D:/601_workspace/poultry_tidy.csv")
poultry %>%
  filter(Product=="Whole") %>%
  arrange(Price_Dollar) %>%
  slice(1:10)
   Product Year    Month Price_Dollar
1    Whole 2004  January      1.97500
2    Whole 2004 February      1.97500
3    Whole 2004    March      2.09000
4    Whole 2004    April      2.12000
5    Whole 2004      May      2.14500
6    Whole 2004     June      2.16375
7    Whole 2006  January      2.17000
8    Whole 2006 February      2.17000
9    Whole 2005  January      2.17000
10   Whole 2005 February      2.17000