chickwtsData SetThe chickwtsdata set is avaiable when the datasets package is loaded.
Data extracted from the chickwts data set includes 2 variables (columns) and 71 observations (rows).
Newly hatched chicks were randomly allocated into six groups, and each group was given a different feed supplement. Their weights in grams after six weeks are given along with feed types.
weight- a numeric variable giving the chick weighted.
feed-a factor giving the feed type.
The following collection of data and graphs displays the relationship between a type of feed and the weight of chicks over a six week period.
library(dplyr)
library(datasets)
library(magrittr)
library(ggplot2)
library(ggthemes)
chickwts
## weight feed
## 1 179 horsebean
## 2 160 horsebean
## 3 136 horsebean
## 4 227 horsebean
## 5 217 horsebean
## 6 168 horsebean
## 7 108 horsebean
## 8 124 horsebean
## 9 143 horsebean
## 10 140 horsebean
## 11 309 linseed
## 12 229 linseed
## 13 181 linseed
## 14 141 linseed
## 15 260 linseed
## 16 203 linseed
## 17 148 linseed
## 18 169 linseed
## 19 213 linseed
## 20 257 linseed
## 21 244 linseed
## 22 271 linseed
## 23 243 soybean
## 24 230 soybean
## 25 248 soybean
## 26 327 soybean
## 27 329 soybean
## 28 250 soybean
## 29 193 soybean
## 30 271 soybean
## 31 316 soybean
## 32 267 soybean
## 33 199 soybean
## 34 171 soybean
## 35 158 soybean
## 36 248 soybean
## 37 423 sunflower
## 38 340 sunflower
## 39 392 sunflower
## 40 339 sunflower
## 41 341 sunflower
## 42 226 sunflower
## 43 320 sunflower
## 44 295 sunflower
## 45 334 sunflower
## 46 322 sunflower
## 47 297 sunflower
## 48 318 sunflower
## 49 325 meatmeal
## 50 257 meatmeal
## 51 303 meatmeal
## 52 315 meatmeal
## 53 380 meatmeal
## 54 153 meatmeal
## 55 263 meatmeal
## 56 242 meatmeal
## 57 206 meatmeal
## 58 344 meatmeal
## 59 258 meatmeal
## 60 368 casein
## 61 390 casein
## 62 379 casein
## 63 260 casein
## 64 404 casein
## 65 318 casein
## 66 352 casein
## 67 359 casein
## 68 216 casein
## 69 222 casein
## 70 283 casein
## 71 332 casein
ckwt <- tbl_df(chickwts)
ckwt
# A tibble: 71 x 2
weight feed
<dbl> <fctr>
1 179 horsebean
2 160 horsebean
3 136 horsebean
4 227 horsebean
5 217 horsebean
6 168 horsebean
7 108 horsebean
8 124 horsebean
9 143 horsebean
10 140 horsebean
# ... with 61 more rows
ckwt.wt.feed <- ckwt %>%
ggplot(aes(x=feed, y=weight)) +
geom_count(color="blue")+
labs(title="Relationship Between Chick Weight & Type of Feed",
x="Feed Type", y="Weight in Grams")+
theme_calc()
ckwt.wt.feed
ckwt.num.feed <- ckwt %>%
ggplot(aes(feed)) +
geom_bar(color="red") +
labs(title="Number of Chicks Fed Each Type of Feed",
x="Feed Type", y="Number of Chicks")+
theme_base()
ckwt.num.feed
sum.ckwt<-ckwt %>%
group_by(feed) %>%
summarise(min.weight=min(weight),
max.weight=max(weight),
mean.weight=mean(weight))
sum.ckwt
## # A tibble: 6 x 4
## feed min.weight max.weight mean.weight
## <fctr> <dbl> <dbl> <dbl>
## 1 casein 216 404 323.5833
## 2 horsebean 108 227 160.2000
## 3 linseed 141 309 218.7500
## 4 meatmeal 153 380 276.9091
## 5 soybean 158 329 246.4286
## 6 sunflower 226 423 328.9167
sum.ckwt2 <- sum.ckwt %>%
ggplot(aes(x=feed, y=min.weight)) +
geom_point() +
labs(title="Minimum Weight by Type of Feed", y="Chick Weight(grams)",
x="Feed Type") +
theme_economist_white()
sum.ckwt2
ggplot(sum.ckwt, aes(x=feed, y=max.weight))+
geom_point()+
labs(title="Maximum Weight by Type of Feed", x="Feed Type",
y="Chick Weight(grams)") +
theme_excel()
sum.ckwt3 <- sum.ckwt %>%
ggplot(aes(x=feed, y=mean.weight)) +
geom_point(color="green") +
labs(title="Mean Weight by Type of Feed", y="Chick Weight(grams)",
x="Feed Type") +
theme_bw()
sum.ckwt3